From 18159654cd1f23c0e502750cd816703840c40391 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:39:04 +0800 Subject: [PATCH 01/10] Committed on or around 2023/10/05 --- ...lementing_Interfaces_implement_clause.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Chapter8/Interface/Implementing_Interfaces_implement_clause.java diff --git a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java new file mode 100644 index 0000000..129d1b1 --- /dev/null +++ b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java @@ -0,0 +1,57 @@ +package Interface; + +// An interface specifies what to do, not how to do. +interface management{ + + void parenting(); + void baby_talks(); + + +} + +class parents { + + String fatherString; + String motherString; + +} + + +class kids extends parents implements management{ + + @Override + public void parenting() { + // TODO Auto-generated method stub + System.out.println(fatherString + "'s motherhood"); + } + + @Override + public void baby_talks() { + // TODO Auto-generated method stub + System.out.println( motherString + "'s motherese"); + } + +} + + +public class Implementing_Interfaces_implement_clause { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + kids janeKids = new kids(); + kids peterKids = new kids(); + + janeKids.fatherString = "Jansen"; + janeKids.motherString = "Sharon"; + janeKids.baby_talks(); + janeKids.parenting(); + + + peterKids.fatherString = "Bill"; + peterKids.motherString = "Laura"; + + + } + +} From 4fa8970fd0ebd2f560a372e9fcdbbb10e4bb03e9 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:40:01 +0800 Subject: [PATCH 02/10] Committed on or around 2023/10/05 --- .../Interface/Implementing_Interfaces_implement_clause.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java index 129d1b1..572bf09 100644 --- a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java +++ b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java @@ -22,7 +22,7 @@ class kids extends parents implements management{ @Override public void parenting() { // TODO Auto-generated method stub - System.out.println(fatherString + "'s motherhood"); + System.out.println(fatherString + "'s fatherhood"); } @Override From a73fae67cfac0c1aa60acd95c08d3116c3db94c0 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:48:56 +0800 Subject: [PATCH 03/10] Committed on or around 2023/10/05 --- .../Interface/Implementing_Interfaces_implement_clause.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java index 572bf09..d44bfa4 100644 --- a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java +++ b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java @@ -50,6 +50,8 @@ public static void main(String[] args) { peterKids.fatherString = "Bill"; peterKids.motherString = "Laura"; + peterKids.baby_talks(); + peterKids.parenting(); } From de13f543a0a03bd592b7a48dddb45ddeba8d713e Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 18:50:57 +0800 Subject: [PATCH 04/10] Committed on or around 2023/10/05 --- .../Interface/Implementing_Interfaces_implement_clause.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java index d44bfa4..ec8178e 100644 --- a/Chapter8/Interface/Implementing_Interfaces_implement_clause.java +++ b/Chapter8/Interface/Implementing_Interfaces_implement_clause.java @@ -16,7 +16,7 @@ class parents { } - +// The general form of a class that includes the implements clause looks like this: class kids extends parents implements management{ @Override From baa899fc11f4d63634d9e66fdb76c3768fdcef43 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:47:36 +0800 Subject: [PATCH 05/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Chapter11/Creating_a_Thread.java diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java new file mode 100644 index 0000000..da5a3a8 --- /dev/null +++ b/Chapter11/Creating_a_Thread.java @@ -0,0 +1,11 @@ +// Create a thread by implementing Runnable. + + +public class Creating_a_Thread { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From ed8b5f59ab8ece9567e600ba78929df0c9d20250 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:48:58 +0800 Subject: [PATCH 06/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java index da5a3a8..d8af544 100644 --- a/Chapter11/Creating_a_Thread.java +++ b/Chapter11/Creating_a_Thread.java @@ -1,4 +1,12 @@ // Create a thread by implementing Runnable. +class MyThread2023 implements Runnable{ + + public void run() { + // TODO Auto-generated method stub + + } + +} public class Creating_a_Thread { From 9b8d771e936cd9a1e7a5c95ab0c88832966e446f Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:50:40 +0800 Subject: [PATCH 07/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java index d8af544..73edd4a 100644 --- a/Chapter11/Creating_a_Thread.java +++ b/Chapter11/Creating_a_Thread.java @@ -1,8 +1,9 @@ // Create a thread by implementing Runnable. class MyThread2023 implements Runnable{ + // Objects of MyThread can be run in their own threads because MyThread implements Runnable. public void run() { - // TODO Auto-generated method stub + } From 0d238109a3b6674b5fe03908250dc1e59403d931 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:55:59 +0800 Subject: [PATCH 08/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java index 73edd4a..58e79e9 100644 --- a/Chapter11/Creating_a_Thread.java +++ b/Chapter11/Creating_a_Thread.java @@ -1,9 +1,27 @@ // Create a thread by implementing Runnable. class MyThread2023 implements Runnable{ // Objects of MyThread can be run in their own threads because MyThread implements Runnable. + + String thrdName; + + public MyThread2023(String name) { + thrdName = name; + } - public void run() { + // Entry point of thread. + public void run() { // Threads start executing here. + + System.out.println(thrdName + " starting."); + try { + for (int count = 0; count < 10; count++) { + + Thread.sleep(400); + + } + } catch (InterruptedException exc) { + // TODO: handle exception + } } From 0919437d73c7408a38ee4549f6c45df75f18c468 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:57:07 +0800 Subject: [PATCH 09/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java index 58e79e9..e226a39 100644 --- a/Chapter11/Creating_a_Thread.java +++ b/Chapter11/Creating_a_Thread.java @@ -18,6 +18,7 @@ public void run() { // Threads start executing here. Thread.sleep(400); + System.out.println("In " + thrdName + ", count is " + count); } } catch (InterruptedException exc) { // TODO: handle exception From 55bb86853c0a1d6f8fc10ef3625768cb1aada368 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:58:17 +0800 Subject: [PATCH 10/10] Committed on or around 2023/10/05 --- Chapter11/Creating_a_Thread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread.java b/Chapter11/Creating_a_Thread.java index e226a39..b3c357b 100644 --- a/Chapter11/Creating_a_Thread.java +++ b/Chapter11/Creating_a_Thread.java @@ -21,7 +21,7 @@ public void run() { // Threads start executing here. System.out.println("In " + thrdName + ", count is " + count); } } catch (InterruptedException exc) { - // TODO: handle exception + System.out.println(thrdName + " interrupted."); } }