Skip to content

Instantly share code, notes, and snippets.

Created September 27, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3ab20a757143545e320671e0e3911bb3 to your computer and use it in GitHub Desktop.
Save anonymous/3ab20a757143545e320671e0e3911bb3 to your computer and use it in GitHub Desktop.
package club.outdoors;
import java.util.Trad;
import java.util.Ropes;
import java.util.List;
/**
* Trip report for intermediate climbing trip at Cosmic County.
*
* @author Andrew Barnett
*
*/
public class CosmicCracktion extends TripReport {
private final static int NUM_PARTICIPANTS = 10;
private final static int NUM_CARS = 3;
private final static String crag = "Cosmic County";
private List<Participant> participants;
public static void main(String[] args) {
//List of those who went on the trip
String[] participantNames = {"Andrew", "Alastair", "Mate", "Abi", "Des", "Zoe", "Jayne", "Vicky", "Felix", "Kieran"};
//Initialise the trip report
TripReport cosmic = new CosmicCracktion(participantNames);
}
public CosmicCracktion(String[] participantNames) {
super();
//Initialise participant list
//Don't worry if you don't understand code like this
//Just keep reading for the general gist
//Or ask one of the many engineering students in the club to explain
participants = new ArrayList<Participant>();
for(String name: participantNames) {
participants.add(new Participant(name));
}
//Drive to the crag
if(NUM_PARTICIPANTS/NUM_CARS < 5) {
System.out.println("We hate the planet!");
}
List<Car> cars = new ArrayList<Car>();
//Initialise the 3 cars
Car abiCar = new Car("Abi");
cars.add(abiCar);
Car desCar = new Car("Des");
cars.add(desCar);
Car saCar = new Car("Kieran");
cars.add(saCar);
//Assign each car an important task to do on the way to the crag
String location = "Bell Supercrag";
abiCar.get("Club ropes", location);
location = "Blackheath";
desCar.get("Oak", location);
location = null;
saCar.findAndPickup("Alastiar", location);
//Drive all cars to crag
for(Car car : cars) {
car.driveTo(cosmic);
}
//Test for time of arrival.
if(System.currentTimeMillis() < TEN_OCLOCK) {
System.out.println("Early/On-time: This has got to be some kinda record!");
} else {
System.out.println("Late: Don't ever try an alpine start buddy...");
}
//Find our way from the carpark to the crag
Participant abi = participants.get("Abi");
try {
//Get Andrew to navigate because he's supposed to be good at it
//We don't trust him though so we had to surround this code by a try/catch clause.
Navigator andrew = new Navigator("Andrew");
andrew.navigate();
//Walk to crag until arrived
while(participants.walkTo(crag)) {
abi.say("I think we're there... I can feel it");
if(distanceTo(crag) < 500) {
abi.moan(Sounds.SEXUALLY);
abi.say("Look at this amazing crack!");
}
List<Participants> others = participants.getAllExcept("Abi");
others.say("Nah mate, I think your a bit premature");
}
//Finally arrived
abi.scream("It's so beautiful!");
} catch (NavigationException lost) {
System.out.println("Your navigator is terrible try someone else...");
}
//Start the actual climbing
//NOTE: This is where the bulk of execution time is spent.
//Complexity of O(n), could acheive O(log(n)) if each belayer belays two at once
//(probably not safe, better run it past Alastair "Safety" McDowell first)
//Could also improve the efficiency here with multithreading but for the sake of
//readability I will keep to a single thread.
//I think all this code is pretty self explanitory...
Climb i31 = crag.getClimb("Interstate31");
String leader = "Alastair";
String second = "Andrew";
i31.climbTrad(leader, second);
Climb baird = crag.getClimb("Baird's Effort");
leader = "Vicky";
second = "Kieran";
baird.climbTrad(leader, second);
Camera.takePhotos("Des");
leader = "Abi";
second = "Felix";
while(i31.climbTrad(leader, second)) {
abi.moan(Sounds.SEXUALLY, Sounds.LOUD);
}
Climb playground = crag.getClimb("Alison's Playground");
leader = "Mate";
String[] seconds = {"Zoe", "Jayne"};
for(String seconder : seconds) {
playground.climbTrad(leader, seconder);
}
Climb mindblower = crag.getClimb("Mindblower");
leader = "Alastair";
second = "Andrew";
mindblower.climbTrad(leader, second);
mindblower.climbTopRope("Zoe");
mindblower.climbTopRope("Jayne");
leader = "Felix";
second = "Abi";
mindblower.climbTrad(leader, second);
leader = "Andrew";
second = "Alastair";
playground.takeTradginity(leader, second); //Yew yew
crag.goAndClimbByThemselves("Vicky", "Kieran");
i31.climbTopRope("Zoe");
i31.climbTopRope("Jayne");
leader = "Alastair";
second = "Andrew";
//Alastair can't help but drink some oak at this point
Participant al = participants.get("Alastair");
al.drinkOak();
baird.climbTrad(leader, second));
al.vomit("Oak");
al.say("This is the best tasting vomit ever!");
//People continued to climb all day
boolean keen = true;
while(keen) {
keen = participants.climbMore();
}
//Teach some of the new people some anchor skills.
Participant vicky = participants.get("Vicky");
vicky.teach("Zoe", "Kieran", "Jayne");
abi.teach("Zoe", "Kieran", "Jayne");
//Alastair, Abi and Felix test their crack skills
//With speed laps of interstate 31, timing themselves
boolean buggered = false;
String[] speedsters = {"Alastair", "Abi", "Felix"};
Time times[] = new Time[speedsters.length];
while(!buggered) {
for(int i = 0; i < speedsters.length; i++) {
Time newTime = i31.climbTopRopeTimed(speedsters[i]);
if(newTime < times[i]) {
times[i] = newTime;
}
}
}
System.out.println("The winner is Alastair with a time of 1:57");
//Now it is getting dark and people start to pack up
//Those who still have energy can
//go trail running after climbing
String[] haveEnergy = {"Alastair", "Andrew", "Felix"};
saCar.driveTo("Perry's Lookdown");
for(String runner : haveEnergy) {
int elevationChangeMeters = 600;
runner.runDown(elevationChangeMeters);
runner.runUp(elevationChangeMeters);
}
System.out.println("Took less than an hour! New record!");
//Drink oak for recovery.
String[] flavours = {"Chocolate", "Strawberry", "Molten Caramel"}; //Wth Des, no body likes molten caramel...
participants.drinkOak(flavours);
//Eat dinner
for(Car car : cars) {
car.driveTo("Rene's Pizza");
}
boolean full = false;
while(!full) {
participants.banter();
full = participants.eatPizza();
}
//Drive back to Sydney
for(Car car : cars) {
car.driveTo("Sydney");
}
System.out.println("Trip report complete. Thanks Abi, Alastair and Mate for organising! Thanks everyone else for coming along!");
ImageViewer.printImagesBelowCode();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment