forked from scottnakada/HackerRank-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
29 lines (21 loc) · 1.09 KB
/
Main.java
File metadata and controls
29 lines (21 loc) · 1.09 KB
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
package enumExample;
public class Main {
public static void main(String[] args) {
System.out.println("Enum Example");
/* Create a new person with Black hair */
Person peterParker = new Person(HairColors.BLACK);
System.out.println("Creating Peter Parker with " + peterParker.getHairColor() + " hair");
/* Creating an alias Spiderman for Peter Parker */
System.out.println("Creating an alias for Peter Parker, called Spiderman");
Person spiderMan = peterParker;
System.out.println("Spiderman has " + spiderMan.getHairColor() + " hair, just like Peter Parker");
/* Change Peter Parkers hair, and see if spidermans hair changes color */
peterParker.setHairColor(HairColors.BLONDE);
System.out.println("Setting Peter Parkers hair to " + peterParker.getHairColor());
System.out.println("Spidermans hair is now " + spiderMan.getHairColor());
/* Changing Spidermans hair */
spiderMan.setHairColor(HairColors.PINK);
System.out.println("We changed Spiderman's hair to " + spiderMan.getHairColor());
System.out.println("Peter Parkers hair is now " + peterParker.getHairColor());
}
}