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
Binary file removed bin/main/org/8033/assessment/Main.class
Binary file not shown.
Binary file added bin/main/org/frc8033/assessment/Main.class
Binary file not shown.
Binary file added bin/main/org/frc8033/assessment/car/Car.class
Binary file not shown.
Binary file added bin/main/org/frc8033/assessment/car/GasCar.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/test/org/8033/assessment/MainTest.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(17)
}
}

Expand Down
7 changes: 7 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,7 @@
package org.frc8033.assessment.car;


public interface Car {
public float getRangeMi();
public void drive(float distance);
}
30 changes: 30 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,30 @@
package org.frc8033.assessment.car;

public class GasCar implements Car {
final float tankSize;
final float gasMileage;
float currentGas;

public GasCar(float tankSize, float gasMileage) {
this.tankSize = tankSize;
this.gasMileage = gasMileage;
this.currentGas = tankSize;
}

public void drive(float miles) {
float gasUsed = miles/gasMileage;

if (gasUsed > currentGas) {
currentGas = 0;
} else {
currentGas -= gasUsed;
}
}

public float getRangeMi() {
return currentGas * gasMileage;
}
public void fillTank() {
currentGas = tankSize;
}
}
16 changes: 16 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,16 @@
package org.frc8033.assessment.car;

public class HondaAccord extends GasCar {

public HondaAccord() {
super(15, 32);
}

public HondaAccord(float gasMileage, float tankSize) {
super(tankSize, gasMileage);
}

public boolean isStock() {
return gasMileage == 32 && tankSize == 15;
}
}