diff --git a/Bicycle.cpp b/Bicycle.cpp index 87dd0708..ad8e38b6 100644 --- a/Bicycle.cpp +++ b/Bicycle.cpp @@ -31,4 +31,4 @@ string Bicycle::toString() { string s = "-> Bicycle\n\t"; return "-> Bicycle\n" + Vehicle::toString() + "\n\tGears: " + to_string(myGearCount); -} \ No newline at end of file +} diff --git a/Bicycle.h b/Bicycle.h index 61b7ca3d..6e04a4b9 100644 --- a/Bicycle.h +++ b/Bicycle.h @@ -2,6 +2,8 @@ // Created by Esteban Parra on 9/5/19. // +//Edits made by Nicholas Watts where noted + #ifndef DRIVINGSIMULATOR_BICYCLE_H #define DRIVINGSIMULATOR_BICYCLE_H diff --git a/Jet.cpp b/Jet.cpp new file mode 100644 index 00000000..a18325d2 --- /dev/null +++ b/Jet.cpp @@ -0,0 +1,53 @@ +//Created by Nicholas Watts on Oct 4, 2019 +//The functions in this file are modeled on those in Car.cpp and Bicycle.cpp, +//except for where changes were made, as annotated. + +#include "Jet.h" + +Jet::Jet() +{ + numberOfEngines = 0; + setBrand("Unknown"); + setModel("Unknown"); +} + +Jet::Jet(string brand, string model, string fuelType, int numEngines) +{ + setBrand(brand); + setModel(model); + setFuelType(fuelType); + setNumberEngines(numEngines); +} + +Jet::~Jet() = default; + +int Jet::getNumberEngines() +{ + return numberOfEngines; +} + +//NW If the number of engines provided is less than zero, it stays the same. +//Otherwise, the number of engines is updated. +void Jet::setNumberEngines(int newNum) +{ + if (newNum >= 0) + numberOfEngines = newNum; +} + +//NW This function has been changed to match the specifications as given in the +//.pdf provided for the assignment. +double Jet::mileageEstimate(double p_time) +{ + srand(time(NULL)); + double mileage = rand() % 60 + 40.0; + if (numberOfEngines > 2 && fuelType == "Rocket") + mileage += mileage * 0.055 * numberOfEngines; + return mileage; + +} + +string Jet::toString() +{ + return "-> Jet\n" + PoweredVehicle::toString() + "\n\tNumber of Engines: " + + to_string(getNumberEngines()); +} diff --git a/Jet.h b/Jet.h new file mode 100644 index 00000000..6029db8d --- /dev/null +++ b/Jet.h @@ -0,0 +1,27 @@ +//This file was written by Nicholas Watts on Oct 4, 2019. +//Code modeled on Bicycle.h and Car.h in parts, with differences +//in implementation annotated. + +#ifndef DRIVINGSIMULATOR_JET_H +#define DRIVINGSIMULATOR_JET_H + +#include "PoweredVehicle.h" + +class Jet: public PoweredVehicle { + +private: + int numberOfEngines; + +public: + Jet(); + explicit Jet(string brand, string model, string fuelType, + int engineNum = 1); //number of engines to be copied to + //private data + virtual ~Jet(); + int getNumberEngines(); //NW added + void setNumberEngines(int newNum); //NW added + virtual double mileageEstimate(double time); + virtual string toString(); +}; + +#endif diff --git a/Monorail.cpp b/Monorail.cpp new file mode 100644 index 00000000..d0b82a5c --- /dev/null +++ b/Monorail.cpp @@ -0,0 +1,45 @@ +//Created by Nicholas Watts on Oct 4, 2019 + +#include "Monorail.h" + +Monorail::Monorail() +{ + numberCylinders = 0; + setBrand("Unknown"); + setModel("Unknown"); +} + +Monorail::Monorail(string brand, string model, int numCyl) +{ + setBrand(brand); + setModel(model); + setNumberCyl(numCyl); +} + +Monorail::~Monorail() = default; + +int Monorail::getNumberCyl() +{ + return numberCylinders; +} + +void Monorail::setNumberCyl(int newNum) +{ + if (newNum > 0) + numberCylinders = newNum; +} + +double Monorail::mileageEstimate(double p_time) +{ + srand(time(NULL)); + double mileage = rand()%20 + 35; + if(getModel() == "aboveGround") + mileage += mileage * 0.002 * numberCylinders; + return mileage; +} + +string Monorail::toString() +{ + return "-> Monorail\n" + PoweredVehicle::toString() + "\n\tNumber of Cylinders: " + + to_string(getNumberCyl()); +} diff --git a/Monorail.h b/Monorail.h new file mode 100644 index 00000000..70d9a336 --- /dev/null +++ b/Monorail.h @@ -0,0 +1,24 @@ +//Created by Nicholas Watts on March 4, 2019 + +#ifndef DRIVINGSIMULATOR_MONORAIL_H +#define DRIVINGSIMULATOR_MONORAIL_H + +#include "PoweredVehicle.h" + +class Monorail: public PoweredVehicle +{ + + private: + int numberCylinders; + + public: + Monorail(); + explicit Monorail(string brand, string model, int numCyl = 6); + ~Monorail(); + int getNumberCyl(); + void setNumberCyl(int newNum); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + +#endif diff --git a/README.md b/README.md index e69de29b..db7bc62b 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,3 @@ +Name: Nicholas Watts + +FSUID: nsw12b diff --git a/Skateboard.cpp b/Skateboard.cpp new file mode 100644 index 00000000..2dd58e78 --- /dev/null +++ b/Skateboard.cpp @@ -0,0 +1,37 @@ +//Created by Nicholas Watts on Oct 4, 2019 +//Function definitions are based on those in Bicycle.cpp except +//where otherwise annotated. + +#include "Skateboard.h" + +Skateboard::Skateboard(string brand, string model) +{ + setBrand(brand); + setModel(model); +} + +Skateboard::~Skateboard() = default; + +//This function determines the mileage based on the implementation outlined +//in the assignment pdf. The mileage is somewhere between 0.1 and 0.5 miles +//per minute, and an additional amount of minutes if the time is between +//25 and 250 minutes. +double Skateboard::mileageEstimate(double p_time) +{ + srand(time(NULL)); + int addition = 0; + double mileage = rand()%5 + 1.0; + mileage *= 0.1 * p_time; + if (p_time > 25 && p_time < 250) + { + addition = rand()%((int) p_time / 3); + addition += 1; + mileage += addition; + } + return mileage; +} + +string Skateboard::toString() +{ + return "-> Skateboard\n" + Vehicle::toString(); +} diff --git a/Skateboard.h b/Skateboard.h new file mode 100644 index 00000000..6f45377a --- /dev/null +++ b/Skateboard.h @@ -0,0 +1,22 @@ +//Created by Nicholas Watts on Oct 4, 2019 +//The function prototypes in this interface are based off of those +//provided in Bicycle.h, except where annotated. + +#ifndef DRIVINGSIMULATOR_SKATEBOARD_H +#define DRIVINGSIMULATOR_SKATEBOARD_H + +#include "Vehicle.h" + +class Skateboard: public Vehicle +{ + +private: + +public: + explicit Skateboard(string brand, string model); + virtual ~Skateboard(); + virtual double mileageEstimate(double time); + virtual string toString(); +}; + +#endif diff --git a/Skateborad.h b/Skateborad.h new file mode 100644 index 00000000..e69de29b diff --git a/Vehicle.h b/Vehicle.h index 2ac751f3..e4e5d82a 100644 --- a/Vehicle.h +++ b/Vehicle.h @@ -6,7 +6,8 @@ #define DRIVINGSIMULATOR_VEHICLE_H #include // std::string, std::stoi - +#include //NW Added here to make random number generators in all children objects. +#include //NW Same here using namespace std; class Vehicle { diff --git a/docs/answers.txt b/docs/answers.txt new file mode 100644 index 00000000..8084b0bb --- /dev/null +++ b/docs/answers.txt @@ -0,0 +1,74 @@ +a) "Enumerating objects: 8, done. +Counting objects: 100% (8/8), done. +Delta compression using up to 4 threads +Compressing objects: 100% (5/5), done. +Writing objects: 100% (6/6), 672 bytes | 336.00 KiB/s, done. +Total 6 (delta 2), reused 0 (delta 0) +remote: Resolving deltas: 100% (2/2), completed with 1 local object. +remote: +remote: Create a pull request for '45c1cb8' on GitHub by visiting: +remote: https://github.com/NickWattsCS/assignment2/pull/new/45c1cb8 +remote: +To https://github.com/NickWattsCS/assignment2 + * [new branch] HEAD -> 45c1cb8 +" + +The reason that HEADD is pointing to 45c1cb8 and not master is because I had some issues with +pushing the new changes at first. + +b) using the "git log" command, I was able to see that there are currently four commits added +to the reposirtory, all of which were made by me. + +c) I used the commend "git log .gitignore" to find out that the file .gitignore was last updated +'Wed Sep 25 18:13:30 2019 -0400,' as reported by the console. + +d) Branches are used to create an alternative version of the parent directory, either to +differentiate workflow between different users, or to differntiate two functionally different +versions of the repository. + +e) git log returns the commit log of a repository, or returns commit information about a given +commit. In contrast, git status returns the current state of the git machine, and whether there +are any changes between the remote and the local versions of the repository that have yet to been +pushed onto the origin. + +f) To see any commits involving the file Vehicle.h, just type "git log Vehicle.h". + +g) To get all commits that use the word "file," include the flag "--grep='file'" to make the +command line read "git log --grep='file'" + +h) +I) Inheritance is the object-oriented concept where one class is derived from another class, +meaning that the derived class has access to functions from the parent class as well as its own +distinct functions. +II) Polymorphism is a concept of inheritance that says that an object of a derived child class is +also an object of the parent class. +III) Encapsulation is a concept of object-oriented programming where functions and data that +should not be accessible is made private from users. This is to avoid any undesirable +manipulation of sensitive data. + +i) The main difference between the two workflow models is the level of control that the +developers have to push to the blessed repository. In both models, developers can pull from the +blessed repository. However, this is where the two processes diverge. + +Integration management allows developers to push to their own public repositories. From that +point, an integration manager finds and resolves any conflicts between the different +repositories, and publishes the final repository to the blessed repository. In this version, the +developers have more direct control over what appears in the blessed repository. + +In the Dictators and Lieutenants workflow, devlopers must push their repositories to designated +"lieutenant" repositories. From there, a separate entity, the "dictator", merges the two +repositories and resolves any conflicts. This is called the dictator repository, which is then +pushed onto the blessed repository. This allows for more regulatory control over the developers' +individual contributions. + +j) A team of 100 developers would benefit from Dictator and Lieutenant workforce because it +allows the project manager to oversee version control before the work done by those developers is +pushed to the final repository. This allows the project manager to resolve the +torrent of issues that would certainly arise from 100 different versions of one project being +coallesced into one product. This can also give the project manager a level of oversight by +allowing him to insert or remove any code that they may want before pushing it to the blessed +repository. + + +FINAL: Polymorphism is used in the simulator to create the heterogenious list in main.cpp, and +encapsulation is used to store, access, and manipulate member data diff --git a/docs/status.txt b/docs/status.txt new file mode 100644 index 00000000..af92b574 --- /dev/null +++ b/docs/status.txt @@ -0,0 +1,4 @@ +On branch master +Your branch is up to date with 'origin/master'. + +nothing to commit, working tree clean diff --git a/main.cpp b/main.cpp index ba0b6928..202a5434 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,16 @@ #include #include "Car.h" #include "Bicycle.h" +#include "Jet.h" +#include "Skateboard.h" +#include "Monorail.h" void printVehiclesRoster(Vehicle **vehicles, int size); int main() { std::cout << "Driving simulator" << std::endl; - int size = 6; - int capacity = 10; + int size = 10; + int capacity = 15; Vehicle **vehiclesArray = new Vehicle *[capacity]; vehiclesArray[0] = new Car(); @@ -17,6 +20,11 @@ int main() { vehiclesArray[4] = new Bicycle("Mizuno", "Wave", 10); vehiclesArray[5] = new Car("BMW", "X5", "diesel", "grande"); + //These are my own test cases + vehiclesArray[6] = new Monorail(); + vehiclesArray[7] = new Monorail("Wunder", "aboveGround", 15); + vehiclesArray[8] = new Skateboard("Tony Hawk", "Shredder"); + vehiclesArray[9] = new Jet("Boeing", "F50", "Rocket", 6); printVehiclesRoster(vehiclesArray, size); if (vehiclesArray != 0) { // If it is not a null pointer @@ -37,4 +45,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) { << vehicles[i]->mileageEstimate(simulatedDistance) << " miles in " << simulatedDistance << " seconds" << endl; } -} \ No newline at end of file +}