diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..0b071d73 --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,74 @@ +// +// Created by Taylor Driver on 10/3/2019 +// + + +#include "Jet.h" +#include +#include +#include +#include +#include +#include +#include + +Jet::Jet() { + myEngineSize = "unknown"; + myEngineNum = 1; + setBrand("Custom"); + setModel("V6"); +} + +Jet::Jet(string brand, string model, string fuelType, string engineSize, int engineNum) { + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); + setEngineNum(engineNum); +} + + +Jet::~Jet() = default; + +string Jet::getEngineSize() { + return myEngineSize; +} + +int Jet::getEngineNum() { + return myEngineNum; +} + +void Jet::setEngineSize(string engineSize) { + if(engineSize == "unknown" || engineSize == "small" || engineSize == "medium" || engineSize == "grande") { + myEngineSize = engineSize; + } + else + { + myEngineSize = "unknown"; + } +} + +void Jet::setEngineNum(int engineNum) { + myEngineNum = engineNum; +} + +double Jet::mileageEstimate(double time) { + //srand(time(NULL)); + //double mileage = (rand() % 100-39) + 40; + //used Cubbi's answer on StackOverflow's "Random Number c++ in some range" + std::random_device rd; + std::mt19937 rng(rd()); + std::uniform_int_distribution uni(40,100); + int randnum = uni(rng); + double mileage = randnum * time; + + if(fuelType == "Rocket" && myEngineNum == 2) + mileage = mileage + 5.5; + + return mileage; +} + + +string Jet::toString() { + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " + getEngineSize(); +} diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..1dfed0fb --- /dev/null +++ b/Jet.h @@ -0,0 +1,30 @@ +// +// Created by Taylor Driver on 9/5/19 +// + +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet : public PoweredVehicle { + +private: + int myEngineNum; + string myEngineSize; + +public: + Jet(); + + explicit Jet(string brand, string model, string fuelType, string engineSize, int engineNum); + + virtual ~Jet(); + string getEngineSize(); + int getEngineNum(); + void setEngineSize(string engineSize); + void setEngineNum(int engineNum); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + +#endif //DRIVINGSIMULATOR_JET_H diff --git a/README.md b/README.md index e69de29b..f0e082d7 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,2 @@ +Name: Taylor Driver +FSUID: trd16 diff --git a/RollerCoaster.cpp b/RollerCoaster.cpp new file mode 100644 index 00000000..e539b0a8 --- /dev/null +++ b/RollerCoaster.cpp @@ -0,0 +1,74 @@ +// +// Created by Taylor Driver on 10/3/19 +// + +#include "RollerCoaster.h" + +RollerCoaster::RollerCoaster() { + myEngineSize = "unknown"; + myManufacturer = "unknown"; + myName = "unknown"; + myModel = "unknown"; +} + +RollerCoaster::RollerCoaster(string manufacturer, string name, string model, string fuelType, string engineSize) { + setManufacturer(manufacturer); + setName(name); + setModel(model); + setFuelType(fuelType); + setEngineSize(engineSize); +} + + +RollerCoaster::~RollerCoaster() = default; + +string RollerCoaster::getEngineSize() { + return myEngineSize; +} + +string RollerCoaster::getManufacturer() { + return myManufacturer; +} + +string RollerCoaster::getName() { + return myName; +} + +string RollerCoaster::getModel() { + return myModel; +} + +void RollerCoaster::setEngineSize(string engineSize) { + if(engineSize == "unknown" || engineSize == "small" || engineSize == "medium" || engineSize == "grande") + myEngineSize = engineSize; + else + myEngineSize = "unknown"; +} + +void RollerCoaster::setManufacturer(string manufacturer) { + myManufacturer = manufacturer; +} + +void RollerCoaster::setName(string name) { + myName = name; +} + +void RollerCoaster::setModel(string model) { + myModel = model; +} + +double RollerCoaster::mileageEstimate(double time) { + //srand((unsigned)time(0)); + double mileage = time * 20; + + if(myModel == "Wooden") + double mileage = time * ((rand() % 72-4) + 5); + + +return mileage; +} + + +string RollerCoaster::toString() { + return "-> RollerCoaster" + std::string("\n\tManufacturer: ") + getManufacturer() + std::string("\n\tModel: ") + getModel() + std::string("\n\tName: ") + getName() + std::string("\n\tFuel Type: ") + getFuelType() + std::string("\n\tEngine Size: ") + getEngineSize(); +} diff --git a/RollerCoaster.h b/RollerCoaster.h new file mode 100644 index 00000000..3f8610b8 --- /dev/null +++ b/RollerCoaster.h @@ -0,0 +1,35 @@ +// +// Created by Taylor Driver on 10/3/19 +// + +#ifndef DRIVINGSIMULATOR_ROLLERCOASTER_H +#define DRIVINGSIMULATOR_ROLLERCOASTER_H + +#include "PoweredVehicle.h" + +class RollerCoaster : public PoweredVehicle { + +private: + string myEngineSize; + string myManufacturer; + string myName; + string myModel; +public: + RollerCoaster(); + + explicit RollerCoaster(string manufacturer, string name, string model, string fuelType, string engineSize); + + virtual ~RollerCoaster(); + string getEngineSize(); + string getManufacturer(); + string getName(); + string getModel(); + void setManufacturer(string manufacturer); + void setEngineSize(string engineSize); + void setName(string name); + void setModel(string model); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + +#endif //DRIVINGSIMULATOR_ROLLERCOASTER_H diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..a1f632d8 --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,44 @@ +// +//Created by Taylor Driver on 10/3/19 +// + +#include "Skateboard.h" +#include +#include +#include +#include +#include + +Skateboard::Skateboard(string brand, string model) { + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +double Skateboard::mileageEstimate(double time) { + //double mileage = .5 + (std::rand() % (.5-.1+1)) //(double) rand()/(.5 + 1) + .1 + ((double)rand()%.4); + //mileage = (int) floor(mileage); + //double mileage = rand() * 1.0 / .5 * (.5-.1+1) + .1; + //used Cubbi's answer on StackOverflow's "random number c++ in some range" + + std::random_device rd; + std::mt19937 rng(rd()); + std::uniform_real_distribution dist(0.1,0.5); + double randnum = dist(rng); + + double mileage = randnum * time; + + if(time>25.0 && time < 250.0){ + //mileage = mileage + (double)rand()/(time/3) + 1; + std::uniform_real_distribution dist(0.1,time/3); + mileage = mileage + dist(rng); + } +} + +string Skateboard::toString() { + string s = "-> Skateboard\n\t"; + return "-> Skateboard\n" + Vehicle::toString(); + + +} diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..d01ba1e4 --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,23 @@ +// +// Created by Taylor Driver on 10/3/2019 +// + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Vehicle.h" + +class Skateboard : public Vehicle { + + +public: + explicit Skateboard(string brand, string model); + + virtual ~Skateboard(); + virtual double mileageEstimate(double time); + + virtual string toString(); +}; + +#endif //DRIVINGSIMULATOR_SKATEBOAD_H + diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..41fe2246 --- /dev/null +++ b/docs/answers.txt @@ -0,0 +1,78 @@ +// +// Taylor Driver created on 10/4/2019 +// + + +4. +a) + +Counting objects: 5, done. +Delta compression using up to 56 threads. +Compressing objects: 100% (2/2), done. +Writing objects: 100% (4/4), 383 bytes | 0 bytes/s, done. +Total 4 (delta 1), reused 0 (delta 0) +remote: Resolving deltas: 100% (1/1), completed with 1 local object. +To https://github.com/trd16/assignment2.git + dcde9a6..764adcd master -> master + +b) + +There have been 9 commits that have been done to the repository and I used +the [git rev-list --all --count] command to get this information. + +c) + +The .gitignore file was last modified on Wednesday September 25th and I used +the [git log .gitignore] command to get this information. + +d) + +Branches are used in a Git repository to retain the history of the original +line of development while also allowing mutliple people to work on a single +code work at the same time. + +e) + +Git log is used as a running record of commits while git status displays +the state of the working direcotry and lets you see which changes have +been made. + +f) + +I would use the command [git log -p Vehicle.h] to see when this specific +files was committed. + +g) + +I would use the command [git log --all --grep='file'] to see which commits +have commit messages with the word "file". + +h) + +In object oriented programming, inheritance is used to allow new objects to +take on properties of existing objects. Polymorphism is the concept of +objects of different types being accessed through the same interface. +Encapsulation is the briging together of data and methods that work +together in one unit like a class. + +i) + +The main difference between the dictator and lieutenants workflow +and the integration manager workflow is that dictator and lieutenants only +has one central repository that everyone pulls from and the dictator pushes +to while integration manager has two repositories per developer and each +developer can push or pull. + +j) + +How would a team of 100 developers benefit from following the "dicator and +lieutenants" workflow instead of the "centralized" workflow? +A team of 100 developers could benefit from using the dictator and lieutenants +workflow instead of the centralized workflow because instead of every developer +having to resolve conflicts before pushing only the dictator will control this +and there will be less issues arising or differences between code. + + +5. +The Driving simulator prototype is using polymorphism and I can tell this because +function overloading can occur and the classes all inherit from one specific class. diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..e69de29b diff --git a/main.cpp b/main.cpp index ba0b6928..2066ccb1 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,18 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "RollerCoaster.h" void printVehiclesRoster(Vehicle **vehicles, int size); int main() { + srand((unsigned)time(0)); + std::cout << "Driving simulator" << std::endl; - int size = 6; - int capacity = 10; + int size = 12; + int capacity = 12; Vehicle **vehiclesArray = new Vehicle *[capacity]; vehiclesArray[0] = new Car(); @@ -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("Cessna", "Citation", "diesel", "grande",2); + vehiclesArray[7] = new Jet("Learjet", "31", "diesel", "grande",1); + vehiclesArray[8] = new Skateboard("Zero", "Sandoval"); + vehiclesArray[9] = new Skateboard("Element", "Jaakko"); + vehiclesArray[10] = new RollerCoaster("Intamin","Taron", "Steel","diesel", "medium"); + vehiclesArray[11] = new RollerCoaster("Vekoma", "Invertigo", "Steel", "diesel", "grande"); printVehiclesRoster(vehiclesArray, size); @@ -37,4 +48,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) { << vehicles[i]->mileageEstimate(simulatedDistance) << " miles in " << simulatedDistance << " seconds" << endl; } -} \ No newline at end of file +}