Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5059634
Added name and handle
NickWattsCS Oct 3, 2019
6f4b436
Added status file to docs folder.
NickWattsCS Oct 4, 2019
45c1cb8
Merge branch 'master' into HEAD
NickWattsCS Oct 4, 2019
98dae1f
Merge pull request #1 from NickWattsCS/45c1cb8
NickWattsCS Oct 4, 2019
3bd8a3f
Adding the doc answers.txt to the docs folder
NickWattsCS Oct 4, 2019
288fc51
=added answers b through e in answers.txt
NickWattsCS Oct 4, 2019
73f2cb8
=Added f and g to answers.txt
NickWattsCS Oct 4, 2019
27f20e3
added part h to answers.txt
NickWattsCS Oct 4, 2019
14a9338
added i to answers.txt
NickWattsCS Oct 5, 2019
b37dc56
Added part i to answers.txt
NickWattsCS Oct 5, 2019
8d9895d
Edited README to make the newline more pronounced
NickWattsCS Oct 5, 2019
84524d9
Added numberOfGears and mileage member data to Bicyle.h
NickWattsCS Oct 5, 2019
6c6555f
Restored Bicycle.h and Bicycle.cpp to their original versions
NickWattsCS Oct 5, 2019
3b8ba54
Added Jet, Skateboard, and Monorail source files
NickWattsCS Oct 5, 2019
59e016e
Added interface to Jet.h
NickWattsCS Oct 5, 2019
b97209e
Made numEngines a default parameter
NickWattsCS Oct 5, 2019
1516451
Included Cstdlib in Vehicle.h
NickWattsCS Oct 5, 2019
381af07
Added function definitions
NickWattsCS Oct 5, 2019
823e371
Added interface
NickWattsCS Oct 5, 2019
1db9cd9
Changed method of calculating mileage
NickWattsCS Oct 5, 2019
bf9dd45
Added function definitions
NickWattsCS Oct 5, 2019
2a378ef
Added function prototypes
NickWattsCS Oct 5, 2019
18892a8
Included <time>
NickWattsCS Oct 5, 2019
3e8e477
Added function definitions
NickWattsCS Oct 5, 2019
47033e9
Removed mistake file Skateborad.h
NickWattsCS Oct 5, 2019
e4bc74d
Changed <time> to <ctime>
NickWattsCS Oct 5, 2019
dc9bf2c
Changed time(0) to time(NULL), added to_string in toString
NickWattsCS Oct 5, 2019
6f58e6c
Changed parameter time in estimatedMileage to p_time
NickWattsCS Oct 5, 2019
f5908bb
Changed parameter time to p_time
NickWattsCS Oct 5, 2019
10a8d7b
Added changes to get compiler to recognize Monorail constructor
NickWattsCS Oct 5, 2019
cbbc4ec
Fixed code to support Monorail constructor
NickWattsCS Oct 5, 2019
43f64c1
Added last answer
NickWattsCS Oct 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Bicycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ string Bicycle::toString() {
string s = "-> Bicycle\n\t";
return "-> Bicycle\n" + Vehicle::toString() + "\n\tGears: " +
to_string(myGearCount);
}
}
2 changes: 2 additions & 0 deletions Bicycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
53 changes: 53 additions & 0 deletions Jet.cpp
Original file line number Diff line number Diff line change
@@ -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());
}
27 changes: 27 additions & 0 deletions Jet.h
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions Monorail.cpp
Original file line number Diff line number Diff line change
@@ -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());
}
24 changes: 24 additions & 0 deletions Monorail.h
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Name: Nicholas Watts

FSUID: nsw12b
37 changes: 37 additions & 0 deletions Skateboard.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
22 changes: 22 additions & 0 deletions Skateboard.h
Original file line number Diff line number Diff line change
@@ -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
Empty file added Skateborad.h
Empty file.
3 changes: 2 additions & 1 deletion Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#define DRIVINGSIMULATOR_VEHICLE_H

#include <string> // std::string, std::stoi

#include <cstdlib> //NW Added here to make random number generators in all children objects.
#include <ctime> //NW Same here
using namespace std;

class Vehicle {
Expand Down
74 changes: 74 additions & 0 deletions docs/answers.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions docs/status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
14 changes: 11 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <iostream>
#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();
Expand All @@ -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
Expand All @@ -37,4 +45,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) {
<< vehicles[i]->mileageEstimate(simulatedDistance) << " miles in "
<< simulatedDistance << " seconds" << endl;
}
}
}