JAVA
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
// https://www.sololearn.com/Discuss/794898/?ref=app
public class Program {
public static void main(String[] zephyr_koo) {
Pokemon pikachu = new Pokemon();
pikachu.setType("electric");
Pokeball masterBall = new Pokeball("Masterball"); // initialize type via constructor
System.out.println("A wild PIKACHU (" + pikachu.getType() + ") appeared!");
System.out.println("Pika pika pi~~~");
System.out.println("Gotcha! You caught it with a " + masterBall.getType() + "!");
}
}
public class Pokemon {
private String type;
void setType(String type) {
this.type = type;
}
String getType() {
return type;
}
}
public class Pokeball {
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run