Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions Helicopter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Created by Emilio Faim
//

#include "Helicopter.h"

Helicopter::Helicopter() {
myEngineSize = 1;
setBrand("Custom");
setModel("VTx");
}

Helicopter::Helicopter(string brand, string model, int engineSize) {
setBrand(brand);
setModel(model);
setEngineSize(engineSize);
}

Helicopter::~Helicopter() = default;

int Helicopter::getEngineSize() {
return myEngineSize;
}

void Helicopter::setEngineSize(int size) {
myEngineSize = size;
}

double Helicopter::mileageEstimate(double time) {
int range = (95 - 20) + 1;
int random = range * (rand() / (RAND_MAX + 1.0));
double mileage = random * time;

if (myEngineSize > 1) {
mileage = mileage * (myEngineSize * (0.5));
}
return mileage;
}

string Helicopter::toString() {
return "-> Helicopter\n" + PoweredVehicle::toString() + "\n\tEngine Size: " +
Helicopter::getEngineSize();
}
29 changes: 29 additions & 0 deletions Helicopter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Created by Emilio Faim
//
#ifndef DRIVINGSIMULATOR_HELICOPTER_H
#define DRIVINGSIMULATOR_HELICOPTER_H
#include <stdlib.h>
#include "PoweredVehicle.h"

class Helicopter : public PoweredVehicle {

private:
int myEngineSize;


public:
Helicopter();

explicit Helicopter(string brand, string model,
int engineSize = 1);

virtual ~Helicopter();
int getEngineSize();
void setEngineSize(int size);
virtual double mileageEstimate(double time);
virtual string toString();
};


#endif //DRIVINGSIMULATOR_Helicopter_H
51 changes: 51 additions & 0 deletions Jet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Created by Emilio Faim
//

#include "Jet.h"

Jet::Jet() {
myEngineSize = "unknown";
setBrand("Custom");
setModel("VTx");
numberOfEngines = 1;
}

Jet::Jet(string brand, string model, string fuelType, string engineSize, int numberOfEngines) {
setBrand(brand);
setModel(model);
setFuelType(fuelType);
setEngineSize(engineSize);
}

Jet::~Jet() = default;

string Jet::getEngineSize() {
return myEngineSize;
}

void Jet::setEngineSize(string engineSize) {
if (engineSize == "unknown" || engineSize == "small" ||
engineSize == "medium" || engineSize == "grande") {
myEngineSize = engineSize;
} else {
myEngineSize = "unknown";
}

}

double Jet::mileageEstimate(double time) {
int range = (100 - 40) + 1;
int random = range * (rand() / (RAND_MAX + 1.0));

double mileage = random * time;
if (fuelType == "Rocket" && numberOfEngines >= 2) {
mileage = mileage * (numberOfEngines*(0.055));
}
return mileage;
}

string Jet::toString() {
return "-> Jet\n" + PoweredVehicle::toString() + "\n\tEngine Size: " +
getEngineSize();
}
29 changes: 29 additions & 0 deletions Jet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Created by Emilio Faim
//
#ifndef DRIVINGSIMULATOR_JET_H
#define DRIVINGSIMULATOR_JET_H
#include <stdlib.h>
#include "PoweredVehicle.h"

class Jet : public PoweredVehicle {

private:
string myEngineSize;
int numberOfEngines = 1;

public:
Jet();

explicit Jet(string brand, string model, string fuelType,
string engineSize, int numberOfEngines = 1);

virtual ~Jet();
string getEngineSize();
void setEngineSize(string engineSize);
virtual double mileageEstimate(double time);
virtual string toString();
};


#endif //DRIVINGSIMULATOR_JET_H
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name: Emilio Faim
FSUID: ejf15b


38 changes: 38 additions & 0 deletions Skateboard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Created by Emilio Faim.
//

#include "Skateboard.h"


Skateboard::Skateboard(string brand, string model, int min) {
setBrand(brand);
setModel(model);
setMinutes(min);
}

Skateboard::~Skateboard() = default;

int Skateboard::getMinutes(){
return minutes;
}

void Skateboard::setMinutes(int min){
minutes = min;
}

double Skateboard::mileageEstimate(double time) {
double range = (0.5 - 0.1) + 1;
double mileage = range * ((double)rand() / (RAND_MAX + 1.0));
if (minutes > 25 && minutes <= 250){
int range2 = (minutes/3 - 1) + 1;
mileage = range2 * (rand() / (RAND_MAX + 1.0));
}
return mileage;
}

string Skateboard::toString() {
string s = "-> Skateboard\n\t";
return "-> Skateboard\n" + Vehicle::toString() + "\n\tMinutes: " +
to_string(minutes);
}
27 changes: 27 additions & 0 deletions Skateboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Created by Emilio Faim.
//

#ifndef DRIVINGSIMULATOR_SKATEBOARD_H
#define DRIVINGSIMULATOR_SKATEBOARD_H
#include <stdlib.h>
#include "Vehicle.h"

class Skateboard : public Vehicle {

private:
int minutes;

public:
explicit Skateboard(string brand, string model, int min);

virtual ~Skateboard();
int getMinutes();
void setMinutes(int min);
virtual double mileageEstimate(double time);

virtual string toString();
};


#endif //DRIVINGSIMULATOR_Skateboard_H
Binary file added Vehicle.h.gch
Binary file not shown.
102 changes: 102 additions & 0 deletions docs/answers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//Answers.txt

(a) Paste the console output you saved at the end of step 3.C (2 points)

(base) wc-dhcp201d240:assignment2 emiliofaim$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean



(b) How many commits have been done to the repository (not only by you, but by anyone) so far? Write the git command you used to get this information (4 points)

(base) wc-dhcp201d240:docs emiliofaim$ git rev-list --all --count
9



(c) When was the .gitignore file modified last? Write the git command you used to get this information (4 points)

Last time modified was september 25 by Esteban Parra, and the command I used to find out was:
"git log .gitignore"

Sample output:

(base) wc-dhcp201d240:assignment2 emiliofaim$ git log .gitignore
commit e424a923e80da4772ca789591ef3326230062a71
Author: Esteban Parra <[email protected]>
Date: Wed Sep 25 18:13:30 2019 -0400

-> Tracking .gitignore



(d) Mention two reasons why branches are used in a Git repository (4 points)

1. Branches are used to organize and make the workflow more efficient and effortless

2. it will let teams work in parallel and at the same time



(e) What is the difference between git log and git status? (4 points)

The gig log command as it is stated on its documentation shows the commit logs of the file.

The git status command is described also in its documentation, it will show the status of the working three,
not only the file .



(f) What command would you use to see the commits where “Vehicle.h” was one of the committed files? (4 points)

git log --follow Vehicle.h



(g) What command would you use to see the commits whose commit message contains the word “file”? (4 points)

git grep file


(h) In the context of object-oriented programming (I) What is inheritance? (II) What is polymorphism? (III) What is encapsulation? (6 points)


I) Inheritance: It is a mechanism where you can to derive a class from another class that share a set
of attributes and methods

II) Polymorphism: When you override the method inherited from the supper class and then you modify it depending
on the needs

III) Encapsulation: the idea of bundling data and methods in order to be used inside of that unit. for example: classes

Read the “Git Commands, workflow, and resources.pdf” file on Canvas and answer the following questions:
(i) What is the main difference between the “Dictator and Lieutenants” workflow and the “Integration manager” workflow? (5 points)

Dictator and Lieutenants:
Distributed development and integration.
central repository
merges changes in the lieutenants repos and solve the problems
Lieutenants repos: merge some changes and solves errors

Integration manager:
each developer makes their own push and all o the pull from the same repository
integration conflict resolution are done by the integration manager
Each developer makes pull and push to his/her own public repository


(j) How would a team of 100 developers benefit from following the “Dictator and Lieutenants” workflow instead of the “Centralized” workflow? (5 points)

A group with a big amount of developers can be benefited from the dictator workflow because all the push pass by
one person the dictatir who have the responsability of checking the work and make sure the quality of the code.


PART 5

Is the Driving simulator prototype using polymorphism and/or encapsulation? If you find that the prototype is using any of these two OOP principles,
please discuss in which way the prototype is using it.

In the Driving Simulator we could appreciate the use of encapsulation as I explained before, we used classes in order to use the data available only
for those classes and those methods that are encapsulated inside of them. and we did not override any class in order to apply polymorphism.
6 changes: 6 additions & 0 deletions docs/status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//status.txt file

On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
16 changes: 16 additions & 0 deletions docs/temp_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//temporary output
//first status check
(base) wc-dhcp201d240:assignment2 emiliofaim$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
(use "git add <file>..." to include in what will be committed)

docs/
//second status check
(base) wc-dhcp201d240:assignment2 emiliofaim$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
5 changes: 4 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <iostream>
#include "Car.h"
#include "Bicycle.h"
#include "Skateboard.h"
#include "Jet.h"

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

Expand All @@ -16,6 +18,7 @@ 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();

printVehiclesRoster(vehiclesArray, size);

Expand All @@ -37,4 +40,4 @@ void printVehiclesRoster(Vehicle **vehicles, int size) {
<< vehicles[i]->mileageEstimate(simulatedDistance) << " miles in "
<< simulatedDistance << " seconds" << endl;
}
}
}