From 6868baec843735c7bd40777299d047215f3a8cc7 Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Fri, 22 Apr 2016 10:18:31 +0200 Subject: [PATCH] Weight of Box finished After implementing the Measurable interface, the constant weight of Boxes in the int weight method is 5. Attribute int weight, methods set- and getWeight were removed. --- cicaprojekt/Box.java | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/cicaprojekt/Box.java b/cicaprojekt/Box.java index 01875b6..3a773a3 100644 --- a/cicaprojekt/Box.java +++ b/cicaprojekt/Box.java @@ -2,32 +2,14 @@ package cicaprojekt; public class Box implements cicaprojekt.Pickable, cicaprojekt.Destroyable { - private int weight; - public Box(int w){ + public Box(){ Menu.addTab(); - System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.Box(" + w + ")"); - weight = w; + System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.Box()"); System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.Box()"); Menu.removeTab(); } - public int getWeight(){ - Menu.addTab(); - System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.getWeight()"); - return weight; - System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.getWeight()"); - Menu.removeTab(); - } - - public void setWeight(int w){ - Menu.addTab(); - System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.setWeight(" + w + ")"); - weight = w; - System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.setWeight()"); - Menu.removeTab(); - } - public void destroy() { Menu.addTab(); System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.destroy()"); @@ -41,4 +23,13 @@ public class Box implements cicaprojekt.Pickable, cicaprojekt.Destroyable System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.pick()"); Menu.removeTab(); } + + @Override + public int weight() { + Menu.addTab(); + System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.weight()"); + System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Box.weight()"); + Menu.removeTab(); + return 5; + } }