Update main.java

better encapsulation.
This commit is contained in:
Vikramb987
2019-02-23 13:51:07 -07:00
committed by GitHub
parent f2f1212436
commit eed1ab1432

View File

@@ -1,6 +1,11 @@
public class main { public class main {
private static Player player = new Player(); private Player player = new Player();
public Player getPlayer(){
Player copy = new Player(player);
return copy;
}
public void shop(TaipanShop shop){ public void shop(TaipanShop shop){
shop.setPlayer(player); shop.setPlayer(player);
@@ -16,8 +21,8 @@ public class main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
main main = new main(); main main = new main();
ShipWarfare littyWarfare = new ShipWarfare(player); ShipWarfare littyWarfare = new ShipWarfare(main.getPlayer());
TaipanShop littyShop = new TaipanShop(player); TaipanShop littyShop = new TaipanShop(main.getPlayer());
main.shop(littyShop); main.shop(littyShop);