From 386ecd18d243c30641a12dcb9f5a5080cdf380f9 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 4 Sep 2020 14:11:29 +0800 Subject: [PATCH 1/4] Update purpose in the README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3e3b1da..823b755 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ # The Circus Project + +- Used to demo abstract classes, interfaces, packages +- Can be used to demo branching too \ No newline at end of file From 0409928f6016bd8dcec8d3ea805cc15b580c055f Mon Sep 17 00:00:00 2001 From: kaiwen98 Date: Fri, 4 Sep 2020 17:24:23 +0800 Subject: [PATCH 2/4] Added these changes in lecture --- src/main/java/Animal.java | 10 ++++++---- src/main/java/Asset.java | 3 +++ src/main/java/Bird.java | 2 +- src/main/java/Equipment.java | 3 ++- src/main/java/Trainer.java | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 src/main/java/Asset.java diff --git a/src/main/java/Animal.java b/src/main/java/Animal.java index 956bc52..56c7203 100644 --- a/src/main/java/Animal.java +++ b/src/main/java/Animal.java @@ -1,6 +1,8 @@ -public class Animal { - - public String speak(){ - return null; +public abstract class Animal implements Asset{ + private int value = 10; + public abstract String speak(); + @Override + public int getValue(){ + return value; } } diff --git a/src/main/java/Asset.java b/src/main/java/Asset.java new file mode 100644 index 0000000..c9783d6 --- /dev/null +++ b/src/main/java/Asset.java @@ -0,0 +1,3 @@ +public interface Asset { + int getValue(); +} diff --git a/src/main/java/Bird.java b/src/main/java/Bird.java index 1125ec1..f4b1deb 100644 --- a/src/main/java/Bird.java +++ b/src/main/java/Bird.java @@ -1,4 +1,4 @@ -public class Bird extends Animal { +public abstract class Bird extends Animal { public void fly() { System.out.println("Whee ..."); } diff --git a/src/main/java/Equipment.java b/src/main/java/Equipment.java index 6ef8ffc..0e2f9dd 100644 --- a/src/main/java/Equipment.java +++ b/src/main/java/Equipment.java @@ -1,10 +1,11 @@ -public abstract class Equipment { +public abstract class Equipment implements Asset{ protected int purchasePrice; public Equipment(int purchasePrice) { this.purchasePrice = purchasePrice; } + @Override public int getValue() { return purchasePrice; } diff --git a/src/main/java/Trainer.java b/src/main/java/Trainer.java index 984fee0..0a30056 100644 --- a/src/main/java/Trainer.java +++ b/src/main/java/Trainer.java @@ -12,8 +12,8 @@ public static void main(String[] args) { Duck d2 = (Duck) a; // downcasting train(new Duck()); // train(new Parrot()); - Animal a2 = new Animal(); - Bird b2 = new Bird(); + //Animal a2 = new Animal(); + //Bird b2 = new Bird(); } private static void getToSpeak(Animal animal) { From fc588c44b40176fc0ad1a74e0ff0dc3a8e3bd82a Mon Sep 17 00:00:00 2001 From: kaiwen98 Date: Fri, 4 Sep 2020 17:26:34 +0800 Subject: [PATCH 3/4] Made in lecture changes from another branch --- src/main/java/Duck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Duck.java b/src/main/java/Duck.java index 7492ccf..793e963 100644 --- a/src/main/java/Duck.java +++ b/src/main/java/Duck.java @@ -1,7 +1,7 @@ public class Duck extends Bird { @Override public String speak() { - return "Quack Quack"; + return "Quack Quack Quack"; } @Override From 19c527b99bfd7a90e25bff923926d347b8feef46 Mon Sep 17 00:00:00 2001 From: kaiwen98 Date: Fri, 4 Sep 2020 17:38:02 +0800 Subject: [PATCH 4/4] Revert "Added these changes in lecture" This reverts commit 0409928f6016bd8dcec8d3ea805cc15b580c055f. deleted: src/main/java/Asset.java --- src/main/java/Animal.java | 10 ++++------ src/main/java/Asset.java | 3 --- src/main/java/Bird.java | 2 +- src/main/java/Equipment.java | 3 +-- src/main/java/Trainer.java | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) delete mode 100644 src/main/java/Asset.java diff --git a/src/main/java/Animal.java b/src/main/java/Animal.java index 56c7203..956bc52 100644 --- a/src/main/java/Animal.java +++ b/src/main/java/Animal.java @@ -1,8 +1,6 @@ -public abstract class Animal implements Asset{ - private int value = 10; - public abstract String speak(); - @Override - public int getValue(){ - return value; +public class Animal { + + public String speak(){ + return null; } } diff --git a/src/main/java/Asset.java b/src/main/java/Asset.java deleted file mode 100644 index c9783d6..0000000 --- a/src/main/java/Asset.java +++ /dev/null @@ -1,3 +0,0 @@ -public interface Asset { - int getValue(); -} diff --git a/src/main/java/Bird.java b/src/main/java/Bird.java index f4b1deb..1125ec1 100644 --- a/src/main/java/Bird.java +++ b/src/main/java/Bird.java @@ -1,4 +1,4 @@ -public abstract class Bird extends Animal { +public class Bird extends Animal { public void fly() { System.out.println("Whee ..."); } diff --git a/src/main/java/Equipment.java b/src/main/java/Equipment.java index 0e2f9dd..6ef8ffc 100644 --- a/src/main/java/Equipment.java +++ b/src/main/java/Equipment.java @@ -1,11 +1,10 @@ -public abstract class Equipment implements Asset{ +public abstract class Equipment { protected int purchasePrice; public Equipment(int purchasePrice) { this.purchasePrice = purchasePrice; } - @Override public int getValue() { return purchasePrice; } diff --git a/src/main/java/Trainer.java b/src/main/java/Trainer.java index 0a30056..984fee0 100644 --- a/src/main/java/Trainer.java +++ b/src/main/java/Trainer.java @@ -12,8 +12,8 @@ public static void main(String[] args) { Duck d2 = (Duck) a; // downcasting train(new Duck()); // train(new Parrot()); - //Animal a2 = new Animal(); - //Bird b2 = new Bird(); + Animal a2 = new Animal(); + Bird b2 = new Bird(); } private static void getToSpeak(Animal animal) {