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
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/java/BurnDataStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ public class BurnDataStream implements BurnStream {
// change them to see if you can get the lander to make a soft landing.
// burns are between 0 and 200. This burn array usually crashes.

int burnArray[] = {100, 100, 200, 200, 100, 100, 0, 0, 200, 100, 100, 0, 0, 0, 0};
int burnArray[] = {0,0,200,200,200,200,200,200,200,200,200,200,200,170,100,100,130,95,104,100,100,100,100};
int burnIdx = -1;

public BurnDataStream() { }
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/OnBoardComputer.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
public class OnBoardComputer implements BurnStream {
int burnArray[] = {0,0,200,200,200,200,200,200,200,200,200,200,200,170,100,100,130,95,104,100,100,100,100};
int burnIdx = -1;

@Override
public int getNextBurn(DescentEvent status) {
int burn = 0;

System.out.println(burn); /*hack!*/
return burn;
if (burnIdx < burnArray.length) {
burnIdx++;
System.out.println(burnArray[burnIdx]); /*hack!*/
return burnArray[burnIdx];
}
return 0;
}

}
13 changes: 8 additions & 5 deletions src/main/java/Simulation.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
public class Simulation {
private final Vehicle vehicle;


public Simulation(Vehicle v) {
this.vehicle = v;
}
Expand Down Expand Up @@ -29,8 +30,8 @@ public String gameHeader() {
public String getHeader() {
String s = "";
s = s + "\nTime\t";
s = s + "Velocity\t\t"; s = s + "Fuel\t\t";
s = s + "Altitude\t\t"; s = s + "Burn\n";
s = s + "Velocity\t"; s = s + "Fuel\t\t";
s = s + "Altitude\t"; s = s + "Burn\n";
s = s + "----\t";
s = s + "-----\t\t";
s = s + "----\t\t";
Expand Down Expand Up @@ -73,9 +74,11 @@ public int runSimulation(BurnStream burnSource) {
}

public static void main(String[] args) {
// create a new Simulation object with a random starting altitude
// create a new BurnInputStream
// pass the new BurnInputStream to the runSimulation method
Vehicle ship = new Vehicle(9000);
Simulation newSim = new Simulation(ship);// create a new Simulation object with a random starting altitude
//BurnInputStream bis = new BurnInputStream();// create a new BurnInputStream
OnBoardComputer computer = new OnBoardComputer();
newSim.runSimulation(computer);// pass the new BurnInputStream to the runSimulation method
}

}
30 changes: 17 additions & 13 deletions src/main/java/Vehicle.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public Vehicle(int InitialAltitude) {
public static final int FLYING = 1;

// this is initial vehicle setup
int Altitude= 8000;
int PrevAltitude= 8000;
int Altitude= 9000;
int PrevAltitude= 9000;

int Velocity= 1000;
int Fuel = 12000;
Expand Down Expand Up @@ -54,30 +54,34 @@ public String checkFinalStatus() {

public int computeDeltaV() {
// return velocity + gravity - burn amount
return 0;
return Velocity + Gravity - Burn;
}

public void adjustForBurn(int burnAmount) {
// set burn to burnamount requested
// save previousAltitude with current Altitude
// set new velocity to result of computeDeltaV function.
// subtract speed from Altitude
// subtract burn amount fuel used from tank
Burn = burnAmount;// set burn to burnamount requested
PrevAltitude = Altitude;// save previousAltitude with current Altitude
Velocity = computeDeltaV();// set new velocity to result of computeDeltaV function.
Altitude -= Velocity;// subtract speed from Altitude
Fuel -= burnAmount;// subtract burn amount fuel used from tank
}

public boolean stillFlying() {
// return true if altitude is positive
if(Altitude > 0) {// return true if altitude is positive
return true;
}
return false;
}
public boolean outOfFuel() {
// return true if fuel is less than or equal to zero
return true;
if(Fuel <= 0) {// return true if fuel is less than or equal to zero
return true;
}
return false;
}

public DescentEvent getStatus(int tick) {
// create a return a new DescentEvent object
DescentEvent var = new DescentEvent(tick, Velocity, Fuel, Altitude, Flying);// create a return a new DescentEvent object
// filled in with the state of the vehicle.
return null;
return var;
}

}