Skip to content
Open
37 changes: 37 additions & 0 deletions Jet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "Jet.h"
#include <cstdlib>
#include <ctime>
#include <string>

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;
}
24 changes: 24 additions & 0 deletions Jet.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name: Noal Gesler
FSUID: ntg16
23 changes: 23 additions & 0 deletions Scooter.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
18 changes: 18 additions & 0 deletions Scooter.h
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions Skateboard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Skateboard.h"
#include <cstdlib>
#include <ctime>
#include <string>

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();
}
17 changes: 17 additions & 0 deletions Skateboard.h
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions answers.txt
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <iostream>
#include "Car.h"
#include "Bicycle.h"
#include "Jet.h"
#include "Skateboard.h"
#include "Scooter.h"
#include <cstdlib>
#include <ctime>

void printVehiclesRoster(Vehicle **vehicles, int size);

Expand All @@ -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);

Expand Down
19 changes: 19 additions & 0 deletions status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
On branch master

No commits yet

Untracked files:
(use "git add <file>..." 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)