diff --git a/Bicycle.h b/Bicycle.h index 61b7ca3d..46cd7380 100644 --- a/Bicycle.h +++ b/Bicycle.h @@ -1,5 +1,5 @@ // -// Created by Esteban Parra on 9/5/19. +// Created by Kristen Davis // #ifndef DRIVINGSIMULATOR_BICYCLE_H @@ -10,14 +10,14 @@ class Bicycle : public Vehicle { private: - int myGearCount; + int numberofwheels; public: explicit Bicycle(string brand, string model, int gearCount = 1); virtual ~Bicycle(); int getGearCount(); - void setGearCount(int gearCount); + void setGearlCount(int gearCount); virtual double mileageEstimate(double time); virtual string toString(); diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..d4503d92 --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,51 @@ +// +//Kristen Davis +// +#include +#include +#include "Jet.h" + +Jet::Jet() { + myEngineSize = "unknown"; + setBrand("Custom"); + setModel("VTx"); + setNumberofEngines(1); +} + +Jet::Jet(string brand, string model, string fuelType, int numberOfEngines=1) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); + //setEngineSize(engineSize); + setNumberofEngines(numberOfEngines) +} + +Jet::~Jet() = default; + +string Jet::getNumberofEngines() { + return numberOfEngines; +} + +void Jet::setFuelType(string fuelType) { + fuel=fuelType + } + +} + +double Jet::mileageEstimate(double time) { + double mileage = (rand()%(100-40)+40) * time; + if (fuelType == "rocket" && numberOfEngines>=2) { + mileage += mileage * (0.055); + } + return mileage; +} + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + + getNumberofEngines(); + +void Jet::setNumberofEngines(int ne) +{ + numEngines=ne; +} +} diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..e518ed85 --- /dev/null +++ b/Jet.h @@ -0,0 +1,31 @@ +// +// Created by Esteban Parra on 9/5/19. +// + +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + string fuel; + int numEngines; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, + string engineSize, int numberOfEngines); + + virtual ~Jet(); + string getNumberofEngines(); + void setFuelType(string engineSize); + virtual double mileageEstimate(double time); + virtual string toString(); + void setNumberofEngines(int ne); +}; + + +#endif //DRIVINGSIMULATOR_CAR_H diff --git a/README.md b/README.md index e69de29b..3d781ab9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Kristen Davis +FSUID: knd15e diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..aa9e3514 --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,41 @@ +// +//Kristen Davis +// +#include +#include "Skateboard.h" + + +Skateboard::Skateboard(string brand, string model, int numberofwheels) { + setBrand(brand); + setModel(model); + setGearCount(numberofwheels); +} + +Skateboard::~Skateboard() = default; + +int Skateboard::getWheelCount() { + return numberofwheels; +} + +void Skateboard::setWheelCount(int num) { + numberofwheels = num; +} + +double Skateboard::mileageEstimate(double time) { + random_device rd; + mt19937 en(rd()); + uniform_double_distribution<> distro(.1,.5); + double mileage = distro(en) * time; + if(time>=25 && time<250) + { + double high= time/3; + mileage+=(rand()%(high-1)+1); + } + return mileage; +} + +string Skateboard::toString() { + string s = "-> Skateboard\n\t"; + return "-> Skateboard\n" + Vehicle::toString() + "\nWheels: " + + to_string(numberofwheels); +} diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..35795928 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,27 @@ +// +// Created by Kristen Davis +// + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Vehicle.h" + +class Skateboard : public Vehicle { + +private: + int numberofwheels; + +public: + explicit Skateboard(string brand, string model, int numberofwheels = 4); + + virtual ~Skateboard(); + int getWheelCount(); + void setWheelCount(int numberofwheels); + virtual double mileageEstimate(double time); + + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_BICYCLE_H diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..e1ee60c9 --- /dev/null +++ b/docs/answers.txt @@ -0,0 +1,37 @@ +e.a) On branch master +Your branch is up to date with 'origin/master'. + +e.b) git shortlog +17 + +e.c) git log --follow .gitignore + +Date: Wed Sep 25 18:13:30 2019 -0400 + +e.d) 1)allowing people to review changes + 2)allow's bugs to be fixed when software is live and the fix can be implemented during the next update when the branch is merged with the master. + +e.e) Git status shows the state of the working directory and what changes have been staged and not tracked. Git Log allows you to view information about previous commits that have occurred in the project. + +e.f) git log -p Vehicle.h + +e.g) git log --all --grep='file' + +e.h) Inheritance is a mechanism where you can to derive a class from a family of classes that share attributes. + Polymorphism is a programming language's ability to process objects depending on data type. + Encapsulation is the bundling of data and functions that work on the data in one class. + +e.i) Integration workflows users have public and private +branches to work from. + +e.j) It allows for only one person to push to the master +instead of multiple small developers pushing to the master and +causing issues. + + + +5) The Driving simulator prototype uses polymorphism since it +sets the brand and model of a vehicle regardless of its a +powered vehicle or an unpowerd vehicle. The Driving simulator +prototype uses encapsulation since all the different aspects +of the vehicle are in the private data section. diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..1498befe --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,3 @@ +On branch master +Your branch is up to date with 'origin/master'. + diff --git a/main.cpp b/main.cpp index ba0b6928..1071e0ca 100644 --- a/main.cpp +++ b/main.cpp @@ -1,12 +1,15 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Skateboard.h" +#include "Jet.h" +#include "Tank.h" void printVehiclesRoster(Vehicle **vehicles, int size); int main() { std::cout << "Driving simulator" << std::endl; - int size = 6; + int size = 9; int capacity = 10; Vehicle **vehiclesArray = new Vehicle *[capacity]; @@ -16,7 +19,9 @@ 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 Skateboard("Longboard","Polar",4); + vehiclesArray[7]= new Jet("Boeing","Airbus A350","rocket",4); + vehiclesArray[8]= new Tank("forest", "SoulEater","training"); printVehiclesRoster(vehiclesArray, size); if (vehiclesArray != 0) { // If it is not a null pointer @@ -37,4 +42,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) { << vehicles[i]->mileageEstimate(simulatedDistance) << " miles in " << simulatedDistance << " seconds" << endl; } -} \ No newline at end of file +} diff --git a/tank.cpp b/tank.cpp new file mode 100644 index 00000000..deea0555 --- /dev/null +++ b/tank.cpp @@ -0,0 +1,56 @@ +// +//Kristen Davis +// +#include +#include +#include "Tank.h" + +Tank::Tank() { + nickname="Company X" + setMisson("Training"); + camoflauge="desert"; + setnumberofGuns(2); +} + +Tank::Tank(string camo, string n,string m, int num=2) { + camoflauge=camo; + setMisson(m); + nickname=n; + setNumberofGuns(num); +} + +Tank::~Tank() = default; + +void Tank::getnumberofGuns() { + return numberofGuns; +} + +void Tank::setMisson(string m); +{ + misson=m; +} +double Tank::mileageEstimate(double time) { + double mileage=0; + if(misson=="training") + { + mileage=(rand()%(25-10 +1)+10)*time; + } + else if(misson=="desert") + { + mileage=(rand()%(45-10 +1)+10)*time; + } + else + { + mileage=(rand()%(55-10 +1)+10)*time; + } + return mileage; +} + +string Tank::toString() { + return "-> Tank\n" + PoweredVehicle::toString() + "\n Number of Guns: " + + to_string(numberofGuns); + +void Tank::setNumberofGuns(int ne) +{ + numberofGuns=ne; +} diff --git a/tank.h b/tank.h new file mode 100644 index 00000000..40d429ed --- /dev/null +++ b/tank.h @@ -0,0 +1,31 @@ +// +// Created by Esteban Parra on 9/5/19. +// + +#ifndef DRIVINGSIMULATOR_TANK_H +#define DRIVINGSIMULATOR_TANK_H + +#include "PoweredVehicle.h" + +class Tank : public PoweredVehicle { + +private: + string nickname; + int numberofGuns; + string camoflauge; + string misson; + +public: + Jet(); + + explicit Jet(string camo, string nickname,string misson, int numberofGuns); + virtual ~Jet(); + void getnumberofGuns(); + Void setnumberofGuns(int m); + void setMission(string m); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + + +#endif //DRIVINGSIMULATOR_CAR_H