-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.java
54 lines (42 loc) · 1.76 KB
/
Person.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
public class Person extends Player{
public Person(){
//Take user input
Scanner input = new Scanner(System.in);
//Print out all Pokemon choices and their corresponding index
for (int i = 0; i < 10; i++) {
System.out.println(optionlist.get(i).name + " " + (i + 1));
}
//ask user to choose 1st Pokemon
System.out.println("Choose your Pokemon from under, 3 out of 10. Choose your first Pokemon and input its index.");
String input2 = input.next();
this.choiceindex_1 = Integer.parseInt(input2);
//ask user to choose 2nd Pokemon
System.out.println("Go ahead and choose your second Pokemon and type in its index.");
String input3 = input.next();
this.choiceindex_2 = Integer.parseInt(input3);
//ask user to choose 3rd Pokemon
System.out.println("Choose your last Pokemon and type in its index.");
String input4 = input.next();
this.choiceindex_3 = Integer.parseInt(input4);
//form player's choice list, with order following user's choices
for (int i = 0; i < 10; i++) {
if (i == choiceindex_1-1) {
choicelist.add(optionlist.get(i));
}
}
for (int i = 0; i < 10; i++) {
if (i == choiceindex_2-1) {
choicelist.add(optionlist.get(i));
}
}
for (int i = 0; i < 10; i++) {
if (i == choiceindex_3-1) {
choicelist.add(optionlist.get(i));
}
}
System.out.print("Your choices: " +this.choicelist.get(0).name+" " +choicelist.get(1).name+" " +choicelist.get(2).name);
System.out.print("\n");
System.out.print("\n");
}
}