diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..8a80f20e --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,37 @@ +#include "Jet.h" +#include +#include +#include + +Jet::Jet() { + setBrand("unknown"); + setModel("unkown"); + setNumberOfEngines(1); +} + +Jet::Jet(string brand, string model, string fuelType, int numberOfEngines) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); +} + +Jet::~Jet() = default; + +double Jet::mileageEstimate(double time) { + srand((unsigned)time(0)); + int mileage; + mileage = (rand() % 60) + 41; + if (fuelType == "Rocket" && numberOfEngines >= 2) { + double i = (numberOfEngines * 0.055) + 1; + mileage = mileage * i * time; + } + return mileage; +} + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString(); +} + +void Jet::setNumberOfEngines(int engineCount){ + numberOfEngines = engineCount; +} \ No newline at end of file diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..07a6e285 --- /dev/null +++ b/Jet.h @@ -0,0 +1,24 @@ +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + int numberOfEngines = 1; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, + int numberOfEngines); + + virtual ~Jet(); + virtual double mileageEstimate(double time); + virtual string toString(); + int setNumberOfEngines(int engineCount) +}; + + +#endif //DRIVINGSIMULATOR_JET_H diff --git a/README.md b/README.md index e69de29b..1b1246a5 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Noal Gesler +FSUID: ntg16 \ No newline at end of file diff --git a/Scooter.cpp b/Scooter.cpp new file mode 100644 index 00000000..03ee9ffc --- /dev/null +++ b/Scooter.cpp @@ -0,0 +1,23 @@ +#include "Scooter.h" + + +Scooter::Scooter(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Scooter::~Scooter() = default; + +double Scooter::mileageEstimate(double time) { + int milage = 3 * time; + double i = time * 0.05; + if (time > 30) { + mileage = mileage - i; + } + return mileage; +} + +string Scooter::toString() { + string s = "-> Scooter\n\t"; + return "-> Scooter\n" + Vehicle::toString(); +} \ No newline at end of file diff --git a/Scooter.h b/Scooter.h new file mode 100644 index 00000000..447a9227 --- /dev/null +++ b/Scooter.h @@ -0,0 +1,18 @@ +#ifndef DRIVINGSIMULATOR_SCOOTER_H +#define DRIVINGSIMULATOR_SCOOTER_H + +#include "Vehicle.h" + +class Scooter : public Vehicle { + +public: + explicit Scooter(string brand, string model); + + virtual ~Scooter(); + virtual double mileageEstimate(double time); + + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_SCOOTER_H \ No newline at end of file diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..c3e5f02c --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,28 @@ +#include "Skateboard.h" +#include +#include +#include + +Skateboard::Skateboard(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +double Skateboard::mileageEstimate(double time) { + srand((unsigned)time(0)); + double i = (rand() % 0.4) + 0.1; + int mileage = i * time; + if (time > 25 && time < 250) { + int j = (time / 3) - 1; + int h = (rand() % j) + 1; + mileage = mileage + h; + } + return mileage; +} + +string Bicycle::toString() { + string s = "-> Bicycle\n\t"; + return "-> Bicycle\n" + Vehicle::toString(); +} \ No newline at end of file diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..19e6d7f3 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,17 @@ +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Skateboard.h" + +class Skateboard : public Vehicle { + +public: + explicit Skateboard(string brand, string model); + + virtual ~Skateboard(); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_BICYCLE_H diff --git a/answers.txt b/answers.txt new file mode 100644 index 00000000..a63ba1d2 --- /dev/null +++ b/answers.txt @@ -0,0 +1,24 @@ +a. To https://github.com/NoalGesler/assignment2.git + +b. 2; git rev-list --count HEAD + +c. 7 days ago; git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="%ai {}" {} + +d. Allow for work to happen parallel to each other in different branches and for preparing/testing different versions of the porject. + +e. git log will only view committed history, while git status will allow you to inspect the full directory. + +f. git log --follow -- Vehicle.h + +g. git log --all --grep='file' + +h. + I. A child class inherits properties and variables from its parent + II. Having multiple varieties of the same class/functions from overloading + III. Bundling together data that is often used together such as a class + +i. In Dictator and Lieutenants, pushes by developers are made to lieutenant repositories, while in Integration manager, pushes by developers are made to public repositories + +j. Any changes in the project and errors in the code can be overseen by the Dictator + +5. The Driving simulator prototype is using both polymorphism and encapsulation. It is using polymorphism in that it contains multiple variations of Constructors, such as a default constructor and an explicit constructor. It is using encapsulation in that all classes are child classes of either Vehicle or PoweredVehicle, and PoweredVehicle is a child class of Vehicle. diff --git a/main.cpp b/main.cpp index ba0b6928..eb2662aa 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,11 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Scooter.h" +#include +#include void printVehiclesRoster(Vehicle **vehicles, int size); @@ -16,6 +21,12 @@ int main() { vehiclesArray[3] = new Car("Tesla", "T2", "electricity", "large"); vehiclesArray[4] = new Bicycle("Mizuno", "Wave", 10); vehiclesArray[5] = new Car("BMW", "X5", "diesel", "grande"); + vehiclesArray[6] = new Jet("Brand", "Model", "Rocket", "2"); + vehiclesArray[7] = new Jet("Brand", "Model", "diesel", "1"); + vehiclesArray[8] = new Skateboard("Brand", "Model"); + vehiclesArray[9] = new Skateboard("Tony", "Hawk"); + vehiclesArray[10] = new Scooter("Brand", "Model"); + vehiclesArray[11] = new Scooter("Razor", "Blue"); printVehiclesRoster(vehiclesArray, size); diff --git a/status.txt b/status.txt new file mode 100644 index 00000000..cce0c80f --- /dev/null +++ b/status.txt @@ -0,0 +1,19 @@ +On branch master + +No commits yet + +Untracked files: + (use "git add ..." to include in what will be committed) + .gitignore + Bicycle.cpp + Bicycle.h + Car.cpp + Car.h + PoweredVehicle.cpp + PoweredVehicle.h + README.md + Vehicle.cpp + Vehicle.h + main.cpp + +nothing added to commit but untracked files present (use "git add" to track)