Browse Source

Added Vehicle class

- No compilation error
- Actual functionaility not tested yet
Fixing-travis-yml
BinHong Lee 8 years ago
parent
commit
b567f31ead
4 changed files with 165 additions and 3 deletions
  1. +2
    -2
      Person.cpp
  2. +1
    -1
      Person.hpp
  3. +125
    -0
      Vehicle.cpp
  4. +37
    -0
      Vehicle.hpp

+ 2
- 2
Person.cpp View File

@@ -8,9 +8,9 @@
using namespace std;

//Empty constructor
Person::Person()
Person::Person(int id)
{
this->id = id;
}

//Complete comstructor


+ 1
- 1
Person.hpp View File

@@ -12,7 +12,7 @@ class Person
int id;

public :
Person();
Person(int id);
Person(string, string, string, string, int);
void setName(string);
string getName();


+ 125
- 0
Vehicle.cpp View File

@@ -0,0 +1,125 @@
#include <string>
#include "Vehicle.hpp"
using namespace std;

Vehicle::Vehicle(int length, int width, int id)
{
this->length = length;
this->width = width;
this->id = id;
initialize();
}

Vehicle::Vehicle(string type, int length, int width, string origin, string destination, string dateNtime, int id)
{
this->type = type;
this->length = length;
this->width = width;
this->origin = origin;
this->destination = destination;
this->dateNtime = dateNtime;
this->id = id;
initialize();
}

void Vehicle::setType(string type)
{
this->type = type;
}

void Vehicle::setOrigin(string origin)
{
this->origin = origin;
}

void Vehicle::setDestination(string destination)
{
this->destination = destination;
}

string Vehicle::getType()
{
return type;
}

int Vehicle::getLength()
{
return length;
}

int Vehicle::getWidth()
{
return width;
}

string Vehicle::getOrigin()
{
return origin;
}

string Vehicle::getDestination()
{
return destination;
}

string Vehicle::getDateNTime()
{
return dateNtime;
}

int Vehicle::getId()
{
return id;
}

void Vehicle::initialize()
{
for (int i = 0; i < length; i++)
{
vector<int> row;
for (int j = 0; j < width; j++)
{
row.push_back(-1);
}
seatMap.push_back(row);
}
}

bool Vehicle::bookSeat(int x, int y, int guestId)
{
if (seatMap[x][y] == -1)
{
seatMap[x][y] = guestId;
return true;
}

return false;
}

bool Vehicle::checkAvailabilty(int x, int y)
{
return seatMap[x][y] == -1;
}

void Vehicle::printMap(int guestId)
{
for (int i = 0; i < length; i++)
{
for (int j = 0; j < width; j++)
{
if (seatMap[i][j] == -1)
{
cout << "A ";
}
else if (seatMap[i][j] == guestId)
{
cout << "U ";
}
else
{
cout << "X ";
}
}
cout << endl;
}
}

+ 37
- 0
Vehicle.hpp View File

@@ -0,0 +1,37 @@
#include <string>
#include <iostream>
#include <vector>
using namespace std;

class Vehicle
{
private:
string type;
int length;
int width;
string origin;
string destination;
string dateNtime;
int id;
vector< vector<int> > seatMap;

public:
Vehicle(int length, int width, int id);
Vehicle(string type, int length, int width, string origin, string destination, string dateNtime, int id);
void setType(string type);
void setLength(int length);
void setWidth(int width);
void setOrigin(string origin);
void setDestination(string origin);
string getType();
int getLength();
int getWidth();
string getOrigin();
string getDestination();
string getDateNTime();
int getId();
void initialize();
bool bookSeat(int x, int y, int guestId);
bool checkAvailabilty(int x, int y);
void printMap(int guestId);
};

Loading…
Cancel
Save