From ce31d0f4393b5acf05438db9c22918065eedbb02 Mon Sep 17 00:00:00 2001 From: MikeZyeman Date: Mon, 29 Nov 2021 15:56:52 +0100 Subject: [PATCH] Added superclass structure to roads and settlement --- .idea/misc.xml | 2 +- src/ch/zhaw/catan/Road.java | 15 ++------------- src/ch/zhaw/catan/Structure.java | 9 +++++++++ 3 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 src/ch/zhaw/catan/Structure.java diff --git a/.idea/misc.xml b/.idea/misc.xml index b573818..c3dfb30 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/ch/zhaw/catan/Road.java b/src/ch/zhaw/catan/Road.java index 360e794..5131770 100644 --- a/src/ch/zhaw/catan/Road.java +++ b/src/ch/zhaw/catan/Road.java @@ -1,19 +1,8 @@ package ch.zhaw.catan; -import java.util.HashMap; - -public class Road { - private HashMap buildCost; - private Config.Faction faction; +public class Road extends Structure { public Road(Config.Faction faction) { - this.faction = faction; - buildCost = new HashMap<>(); - buildCost.put(Config.Resource.BRICK,1); - buildCost.put(Config.Resource.LUMBER,1); - } - - public HashMap getBuildCost() { - return buildCost; + super(faction); } } diff --git a/src/ch/zhaw/catan/Structure.java b/src/ch/zhaw/catan/Structure.java new file mode 100644 index 0000000..fc085a2 --- /dev/null +++ b/src/ch/zhaw/catan/Structure.java @@ -0,0 +1,9 @@ +package ch.zhaw.catan; + +public abstract class Structure { + private Config.Faction faction; + + public Structure(Config.Faction faction) { + this.faction = faction; + } +}