Merge remote-tracking branch 'origin/master'

# Conflicts:
#	.idea/workspace.xml
#	src/TaipanShop.java
This commit is contained in:
Vikram
2019-02-19 10:10:11 -07:00
5 changed files with 104 additions and 6 deletions

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="ProjectKey">
<option name="state" value="project://63537948-39a4-48a0-9c97-34259a0fa913" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_191" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_201" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SvnBranchConfigurationManager">

View File

@@ -108,4 +108,9 @@ public class Player {
this.guns = guns;
}
}
public void gameOver() {
System.out.flush();
System.out.println("Game over");
}
}

View File

@@ -49,10 +49,6 @@ public class ShipWarfare extends Player {
TimeUnit.SECONDS.sleep(1);
}
public void gameOver() {
System.out.flush();
System.out.println("Game over");
}
public int numOfShips() {

View File

@@ -1,2 +1,99 @@
public class Travel {
import java.util.Random;
import java.util.Scanner;
public class Travel extends Player {
public void travelTo(){
Scanner keyboard = new Scanner(System.in);
String response;
int tempInt;
boolean hasTraveled = false;
while (true) {
System.out.println("\n" + getName() + ", do you wish to go to:\n");
System.out.println("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\n4) Saigon, 5) Manila, 6) Singapore, or 7) Batavia?");
response = keyboard.nextLine();
try {
tempInt = Integer.parseInt(response);
if(tempInt != getLocation()){
switch (tempInt) {
case 1:
randomEventSea();
System.out.println("\nArriving at Hong Kong");
setLocation(1);
hasTraveled = true;
break;
case 2:
randomEventSea();
System.out.println("\nArriving at Shanghai");
setLocation(2);
hasTraveled = true;
break;
case 3:
randomEventSea();
System.out.println("\nArriving at Nagasaki");
setLocation(3);
hasTraveled = true;
break;
case 4:
randomEventSea();
System.out.println("\nArriving at Saigon");
setLocation(4);
hasTraveled = true;
break;
case 5:
randomEventSea();
System.out.println("\nArriving at Manila");
setLocation(5);
hasTraveled = true;
break;
case 6:
randomEventSea();
System.out.println("\nArriving at Singapore");
setLocation(6);
hasTraveled = true;
break;
case 7:
randomEventSea();
System.out.println("\nArriving at Batavia");
setLocation(7);
hasTraveled = true;
break;
}
}
else System.out.println("\nYou're already here Taipan.");
}
catch (Exception e){
System.out.print("\nSorry, Taipan could you say that again?");
}
if(hasTraveled){break;}
}
}
private void randomEventSea() throws Exception {
ShipWarfare attackShip = new ShipWarfare();
Random rand = new Random();
int randGenNum = rand.nextInt(2) + 1;
System.out.println("\n");
if(randGenNum == 1){
attackShip.peasantFleetAttack();
System.out.println("We made it " + getName());
}
else if(randGenNum == 2){
disaster();
System.out.println("We made it " + getName());
}
}
private void disaster(){
System.out.println("Storm Taipan!");
}
public static void main(String[] args){
Travel ship = new Travel();
ship.travelTo();
}
}