Skip to content

Commit

Permalink
Working form - server side
Browse files Browse the repository at this point in the history
  • Loading branch information
benjyberk committed Jan 2, 2017
0 parents commit f20420d
Show file tree
Hide file tree
Showing 41 changed files with 1,606 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .idea/ADP-ex4.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.6)
project(ADP_ex4)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES Driver.cpp Driver.h MaritalStatus.h Color.h Point.cpp Point.h GraphSquare.cpp GraphSquare.h GridMap.cpp GridMap.h findPath.cpp findPath.h TripInfo.cpp TripInfo.h Passenger.cpp Passenger.h Taxi.cpp Taxi.h CarMaker.h StandardTaxi.cpp StandardTaxi.h LuxuryTaxi.cpp LuxuryTaxi.h TaxiDispatch.cpp TaxiDispatch.h DriverLocationListener.cpp DriverLocationListener.h GameControl.cpp GameControl.h DriverTaxiContainer.cpp DriverTaxiContainer.h)
set(MAIN_FILES main.cpp Clock.cpp Clock.h)
add_executable(ADP_ex4 ${MAIN_FILES} ${SOURCE_FILES})
16 changes: 16 additions & 0 deletions CarMaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef ADVANCED_EX2_CARMAKER_H
#define ADVANCED_EX2_CARMAKER_H

enum CarMaker {
HONDA,
SUBARU,
TESLA,
FIAT
};

#endif //ADVANCED_EX2_CARMAKER_H
10 changes: 10 additions & 0 deletions Clock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#include "Clock.h"

Clock::Clock() {
time = 0;
}
17 changes: 17 additions & 0 deletions Clock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef ADP_EX4_CLOCK_H
#define ADP_EX4_CLOCK_H


class Clock {
public:
int time;
Clock();
};


#endif //ADP_EX4_CLOCK_H
17 changes: 17 additions & 0 deletions Color.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef ADVANCED_EX2_COLOR_H
#define ADVANCED_EX2_COLOR_H

enum Color {
RED,
BLUE,
GREEN,
PINK,
WHITE
};

#endif //ADVANCED_EX2_COLOR_H
56 changes: 56 additions & 0 deletions Driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#include "Driver.h"
#include "TripInfo.h"
#include "Taxi.h"

using namespace std;

Driver::Driver(int n_id, int n_age, MaritalStatus n_mStatus, int n_experience, int n_vehicleID) {
id = n_id;
age = n_age;
maritalStatus = n_mStatus;
yearsExperience = n_experience;
carID = n_vehicleID;
}

int Driver::getID() {
return id;
}

int Driver::getAge() {
return age;
}

MaritalStatus Driver::getMarital() {
return SINGLE;
}

Taxi* Driver::getTaxi() {
return 0;
}

int Driver::getYears() {
return 0;
}

void Driver::setTaxi(Taxi*) {

}



void Driver::notifyListeners() {

}

int Driver::getSatisfaction() {
return 0;
}

void Driver::addListener(DriverLocationListener * listener) {
observers.push_back(listener);
}
49 changes: 49 additions & 0 deletions Driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef ADVANCED_EX2_DRIVER_H
#define ADVANCED_EX2_DRIVER_H

class Taxi;
class DriverLocationListener;

#include <cstdlib>
#include <vector>
#include "MaritalStatus.h"
#include "Taxi.h"
#include "DriverLocationListener.h"
#include "TripInfo.h"

/**
* The driver is essentially a container class for information. His only (cureent)
* method of note is add listener - which simply adds a listener
*/
class Driver {
private:
int id;
int age;
MaritalStatus maritalStatus;
int yearsExperience;
int averageSatisfaction;
int passengers;
int carID;
Taxi* taxi;
std::vector<DriverLocationListener *> observers;
public:
Driver(int, int, MaritalStatus, int, int);
int getID();
int getAge();
MaritalStatus getMarital();
Taxi* getTaxi();
int getSatisfaction();
int getYears();
void setTaxi(Taxi*);
void notifyListeners();
// Add a listener for the driver position
void addListener(DriverLocationListener *);
};


#endif //ADVANCED_EX2_DRIVER_H
20 changes: 20 additions & 0 deletions DriverLocationListener.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#include "DriverLocationListener.h"


void DriverLocationListener::moveEvent(Point * newP) {
currentLocation = newP;
}

Point *DriverLocationListener::getLocation() {
return currentLocation;
}

DriverLocationListener::DriverLocationListener(Point * begin, int driverID) {
currentLocation = begin;
id = driverID;
}
27 changes: 27 additions & 0 deletions DriverLocationListener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef ADVANCED_EX2_DRIVERLOCATIONLISTENER_H
#define ADVANCED_EX2_DRIVERLOCATIONLISTENER_H


#include "Point.h"

/**
* The driver-location-listener class provides a notification when a move event
* has occured.
*/
class DriverLocationListener {
private:
Point * currentLocation;
public:
DriverLocationListener(Point *, int);
void moveEvent(Point *);
Point * getLocation();
int id;
};


#endif //ADVANCED_EX2_DRIVERLOCATIONLISTENER_H
34 changes: 34 additions & 0 deletions DriverTaxiContainer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#include "DriverTaxiContainer.h"

DriverTaxiContainer::DriverTaxiContainer() {
taxi = 0;
driver = 0;
location = new Point(0,0);
}

void DriverTaxiContainer::setDriver(Driver * newDriver) {
driver = newDriver;
}

void DriverTaxiContainer::setTaxi(Taxi * newTaxi) {
taxi = newTaxi;
}

void DriverTaxiContainer::setLocation(Point * newLocation) {
location = newLocation;
}

DriverTaxiContainer::~DriverTaxiContainer() {
if (taxi) {
delete taxi;
}
if (driver) {
delete driver;
}
delete location;
}
29 changes: 29 additions & 0 deletions DriverTaxiContainer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Benjy Berkowicz - 336182589
// Advanced Programming 2016-2017 Bar Ilan
//

#ifndef EX2_V2_DRIVERTAXICONTAINER_H
#define EX2_V2_DRIVERTAXICONTAINER_H

class Taxi;

#include "Taxi.h"

/**
* A container class that holds the driver and the taxi as well as their location
*/
class DriverTaxiContainer {
public:
Taxi * taxi;
Driver * driver;
Point * location;
DriverTaxiContainer();
void setDriver(Driver *);
void setTaxi(Taxi *);
void setLocation(Point *);
~DriverTaxiContainer();
};


#endif //EX2_V2_DRIVERTAXICONTAINER_H
Loading

0 comments on commit f20420d

Please sign in to comment.