File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ public class Character {
2+ private String name ;
3+ private int health ;
4+ private static final int MAX_HEALTH = 100 ;
5+
6+ public Character (String name ) {
7+ this .name = name ;
8+ health = 0 ;
9+ }
10+
11+ public String getName () {
12+ return name ;
13+ }
14+
15+ public void setName (String name ) {
16+ this .name = name ;
17+ }
18+
19+ /* Add a getter for health here. */
20+
21+ /*
22+ * Add a setter for health here. The max health is MAX_HEALTH, so don't set
23+ * health above that.
24+ */
25+ }
Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
13public class Main {
24 public static void main (String [] args ) {
5+ // Scanner scanner = new Scanner(System.in);
6+
7+ // String hello = "Hello World";
8+ // int a = 3;
9+ // boolean b = true;
10+ /* Make a double variable named 'd' with the value 6.28 */
11+
312 System .out .println ("Hello World!" );
13+
14+ // if (a == 3) {
15+ // System.out.println("a is 3! :D");
16+ // } else if (a == 4) {
17+ // System.out.println("a is 4! :>");
18+ // } else {
19+ // System.out.println("a is not 3 or 4! >:c");
20+ // }
21+
22+ /* Counts up from 0 to 5 */
23+ // int i = 0;
24+ // while (i < 5) {
25+ // System.out.println(i);
26+ // i++;
27+ // }
28+
29+ /* Same thing as the while loop above, expressed as a for loop */
30+ // for (int j = 0; j < 5; j++) {
31+ // System.out.println(j);
32+ // }
33+
34+ /* Write while and for loops to count down from 5 to 0 here */
435 }
36+
37+ // This is a void method because it doesn't return anything
38+ // static void sayHi() {
39+ // System.out.println("Hi! :3");
40+ // }
41+
42+ // This method returns a value, it has a return type instead of 'void'
43+ // static double add(double x, double y) {
44+ // return x + y;
45+ // }
46+
47+ /*
48+ * Write a method that takes in two ints and prints out
49+ * "Subtracting <second int> from <first int>", then returns the result of the
50+ * subtraction
51+ */
552}
You can’t perform that action at this time.
0 commit comments