-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
25 lines (23 loc) · 803 Bytes
/
Main.java
File metadata and controls
25 lines (23 loc) · 803 Bytes
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
package Encapsulation;
/**
* Created by robertsg on 12/1/2015.
*/
public class Main {
public static void main(String[] args) {
// Incorrect Way of doing it (Doesn't have encapsulation)
// Player player = new Player();
// player.name = "Tim";
// player.health = 20;
// player.weapon = "Sword";
//
// int damage = 10;
// player.loseHealth(damage);
// System.out.println("Remaining health = " + player.healthRemaining());
//
// damage = 11;
// player.loseHealth(damage);
// System.out.println("Remaining health = " + player.healthRemaining());
EnhancedPlayer player = new EnhancedPlayer("Calix",100,"Sword");
System.out.println("Initial Health is " + player.getHealth());
}
}