Iteration Mini Lab
Boats are better than monkeys
class BoatLoop {
String [][] boats;
String origin;
String destination;
String ocean;
public BoatLoop() {
boats = new String[][]{
{
" __|_|__|_|__",
" _|____________|__",
" |o o o o o o o o / " ,
},
{
" __|_|__|_|__",
" _|____________|__",
" |o o o o o o o o / " ,
},
{
" __|_|__|_|__",
" _|____________|__",
" |o o o o o o o o / " ,
},
{
" __|_|__|_|__",
" _|____________|__",
" |o o o o o o o o / " ,
},
{
" __|_|__|_|__",
" _|____________|__",
" |o o o o o o o o / " ,
}
};
this.getCities();
this.printBoats();
}
public void getCities() {
Scanner input = new Scanner(System.in);
System.out.println("Where are you starting from?");
origin = input.nextLine();
System.out.println(origin);
System.out.println("\nWhere do you want to sail to?");
destination = input.nextLine();
System.out.println(destination);
ocean = String.format("%s---~'`~'`~'`~'`~'`~'`~'`~~'~'`~'`~'`~'`~'`~'`~'`~~'~'`~'`~'`~'`~'`~'`~'`~'~'`~'`~'`~'`~'`~'`~'`~'`~'`~'`~'`--------%s", this.origin, this.destination);
}
public void printBoats() {
for(int i = 0; i < boats.length; i++) {
for(String line: boats[i]) {
System.out.println(line);
}
System.out.println(this.ocean);
}
System.out.println(String.format("Yay! You reached %s", destination));
}
public static void main(String[] args) {
new BoatLoop();
}
}
BoatLoop.main(null);