-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarvelCharacter.java
61 lines (51 loc) · 2.07 KB
/
MarvelCharacter.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
55
56
57
58
59
60
61
public class MarvelCharacter {
private String name, power;
private int comicsAppeared;
public MarvelCharacter() {
name = "";
power = "";
comicsAppeared = 0;
}
public MarvelCharacter(String name, String power, int comicsAppeared) {
this.name = name;
this.power = power;
this.comicsAppeared = comicsAppeared;
}
public String getName() {
return name;
}
public String getPower() {
return power;
}
public int getComicsAppeared() {
return comicsAppeared;
}
public void addPower(String newPower) {
power += ", " + newPower;
}
public void setComicsAppeared(int comicsAppeared) {
this.comicsAppeared = comicsAppeared;
}
public int randComic() {
return (int) (Math.random() * comicsAppeared) + 1;
}
public static void main(String[] args) {
// MarvelCharacter avenger1 = new MarvelCharacter();
MarvelCharacter spiderMan = new MarvelCharacter("Spider-Man", "webbing projection", 300);
MarvelCharacter symbiote = new MarvelCharacter("Venom", "shapeshifting", 144);
System.out.println(symbiote.getName());
symbiote.addPower(spiderMan.getPower());
spiderMan.setComicsAppeared(spiderMan.getComicsAppeared() + 1);
int symbioteComic = symbiote.randComic();
System.out.println(symbioteComic);
MarvelCharacter blueBatman = new MarvelCharacter("Blue Batman", "Laser Vision", 5);
System.out.println("Marvel Character Name: " + blueBatman.name);
System.out.println("Marvel Character Power: " + blueBatman.power);
System.out.println("Marvel Character Comics Appeared: " + blueBatman.comicsAppeared);
blueBatman.addPower("Hearing");
blueBatman.setComicsAppeared(blueBatman.getComicsAppeared() + 2);
System.out.println("Marvel Character Name: " + blueBatman.name);
System.out.println("Marvel Character Power: " + blueBatman.power);
System.out.println("Marvel Character Comics Appeared: " + blueBatman.comicsAppeared);
}
}