Skip to content
Closed
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
6 changes: 6 additions & 0 deletions src/main/java/org/frc8033/assessment/car/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.frc8033.assessment.car;

public interface Car {
public double getRangeMi();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should technically be floats not doubles but not really a problem

public void drive(double distance);
}
43 changes: 43 additions & 0 deletions src/main/java/org/frc8033/assessment/car/GasCar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.frc8033.assessment.car;

public class GasCar implements Car {
private double tankSize;
private double gasMilage;
private double gasInTank;

public GasCar(double tankSize, double gasMilage) {
this.tankSize = tankSize;
this.gasMilage = gasMilage;
this.gasInTank = tankSize;
}

public double getRangeMi() {
return gasInTank*gasMilage;
}

public void drive(double miles) {
double maxRange = getRangeMi();
if (miles >= maxRange) {
gasInTank = 0;
} else {
gasInTank -= (miles / gasMilage);
}
}

public void fillTank() {
this.gasInTank = tankSize;
}

public double getTankSize() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't need to do this but no problem that u did

return this.tankSize;
}

public double getGasMileage() {
return this.gasMilage;
}

public double getGasInTank() {
return this.gasInTank;
}

}
13 changes: 13 additions & 0 deletions src/main/java/org/frc8033/assessment/car/HondaAccord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.frc8033.assessment.car;

public class HondaAccord extends GasCar {
public HondaAccord() {
super(15, 32);
}
public HondaAccord(double tankSize, double gasMilage) {
super(tankSize, gasMilage);
}
public boolean isStock() {
return (getTankSize() == 15 && getGasMileage() == 32);
}
}