From 48f9912c218a135960eb016bc8640ca4c6038977 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 1 Oct 2023 22:01:03 +0800 Subject: [PATCH 1/2] Committed on or around 2023/10/01 --- .../Interface/Implementing_Interfaces.java | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/Chapter8/Interface/Implementing_Interfaces.java b/Chapter8/Interface/Implementing_Interfaces.java index 905d08e..7a9740a 100644 --- a/Chapter8/Interface/Implementing_Interfaces.java +++ b/Chapter8/Interface/Implementing_Interfaces.java @@ -1,7 +1,5 @@ package Interface; -import Cpp.this_keyword; - //An interface specifies what must be done, but not how to get it done. interface Series4{ @@ -133,6 +131,81 @@ public class Implementing_Interfaces { public static void main(String[] args) { // TODO Auto-generated method stub + + ByTwos2_ oByTwos2_ = new ByTwos2_(); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByTwos2_.getNext()); + } + + System.out.println("\nResetting"); + + oByTwos2_.reset(); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByTwos2_.getNext()); + } + + System.out.println("\nStarting at 100"); + + oByTwos2_.setStart(100); + + for (int i = 0; i < 5; i++) { + + System.out.println("Next value is " + oByTwos2_.getNext()); + } + + System.out.println(); + + ByTwos4 oByTwos4 = new ByTwos4(9); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByTwos4.getNext()); + } + + System.out.println("\nResetting"); + + oByTwos4.reset(); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByTwos4.getNext()); + } + + System.out.println("\nStarting at 100"); + + oByTwos4.setStart(100); + + for (int i = 0; i < 5; i++) { + + System.out.println("Next value is " + oByTwos4.getNext()); + } + + System.out.println(); + + ByThrees2 oByThrees2 = new ByThrees2(); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByThrees2.getNext()); + } + + System.out.println("\nResetting"); + + oByThrees2.reset(); + + for (int i = 0; i < 5; i++) { + System.out.println("Next value is " + oByThrees2.getNext()); + } + + System.out.println("\nStarting at 100"); + + oByTwos4.setStart(100); + + for (int i = 0; i < 5; i++) { + + System.out.println("Next value is " + oByThrees2.getNext()); + } + + System.out.println(); } From 381bef204f251fa540d94aaf08ad50e78be95f5e Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 1 Oct 2023 22:02:33 +0800 Subject: [PATCH 2/2] Committed on or around 2023/10/01 --- Chapter8/Interface/Implementing_Interfaces.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter8/Interface/Implementing_Interfaces.java b/Chapter8/Interface/Implementing_Interfaces.java index 7a9740a..d70a107 100644 --- a/Chapter8/Interface/Implementing_Interfaces.java +++ b/Chapter8/Interface/Implementing_Interfaces.java @@ -198,7 +198,7 @@ public static void main(String[] args) { System.out.println("\nStarting at 100"); - oByTwos4.setStart(100); + oByThrees2.setStart(100); for (int i = 0; i < 5; i++) {