From 48093ae1f3b9cad58a00465e48dbdd88331b5965 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:53:45 +0800 Subject: [PATCH 01/25] Committed on or around 2023/09/23 --- .../theoretical/Using_abstract_classes_2.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Chapter7/theoretical/Using_abstract_classes_2.java diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java new file mode 100644 index 0000000..26d1d13 --- /dev/null +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -0,0 +1,26 @@ +package theoretical; + +abstract class TwoDShapes{ + + private double width; + private double height; + private String name; + + public TwoDShapes() { + + width = height = 0.0; + name = "none"; + } +} + + +public class Using_abstract_classes_2 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + + + } + +} From 96aa10c06e8da34f226be8e0ed3ea00ae667874f Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:56:56 +0800 Subject: [PATCH 02/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index 26d1d13..8e71d60 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -11,6 +11,12 @@ public TwoDShapes() { width = height = 0.0; name = "none"; } + + TwoDShapes(double w, double h, String n){ + width = w; + height = h; + name = n; + } } From d73ba2fa2d93b7a6e5411beb737a5fe9d984debf Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:58:56 +0800 Subject: [PATCH 03/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index 8e71d60..d9cd379 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -17,6 +17,13 @@ public TwoDShapes() { height = h; name = n; } + + TwoDShapes(double x, String n){ + + width = height = x; + name = n; + + } } From f3c9491fafbdacc41f9092bd9ee77b5a26d44081 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:02:49 +0800 Subject: [PATCH 04/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index d9cd379..144ee64 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -19,10 +19,15 @@ public TwoDShapes() { } TwoDShapes(double x, String n){ - width = height = x; name = n; - + } + + // Construct an object from an object. + TwoDShapes(TwoDShapes ob){ + width = ob.width; + height = ob.height; + name = ob.name; } } From 075903c706565e9eef03f526f714228158c28c53 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:44:28 +0800 Subject: [PATCH 05/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index 144ee64..8d3275c 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -29,6 +29,16 @@ public TwoDShapes() { height = ob.height; name = ob.name; } + + + double getWidth() { + return width; + } + + double getHeight() {return height;} + void setWidth(double w) { width = w;} + void setHeight(double h) {height = h;} + String getName() {return name;} } From 24092cababaeb09686e3de03028bbc539f7b45d1 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:46:59 +0800 Subject: [PATCH 06/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index 8d3275c..4c22c9c 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -39,6 +39,12 @@ public TwoDShapes() { void setWidth(double w) { width = w;} void setHeight(double h) {height = h;} String getName() {return name;} + void showDimension() { + System.out.println("Width and height are " + width + " and " + height); + } + + // Now, area() is abstract. + abstract double area(); } From 2a8ab0bcb2877b47a24a22e15c36887ec845992d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:48:54 +0800 Subject: [PATCH 07/25] Commmitted on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index 4c22c9c..b4f9391 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -48,6 +48,13 @@ void showDimension() { } +class Triangle extends TwoDShapes{ + + private String style; + +} + + public class Using_abstract_classes_2 { public static void main(String[] args) { From cedd526b6995d969da61da970119e972ade19c6d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:44:12 +0800 Subject: [PATCH 08/25] Committed on or around 2023/09/23 --- Chapter7/theoretical/Using_abstract_classes_2.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Chapter7/theoretical/Using_abstract_classes_2.java b/Chapter7/theoretical/Using_abstract_classes_2.java index b4f9391..50dfcfd 100644 --- a/Chapter7/theoretical/Using_abstract_classes_2.java +++ b/Chapter7/theoretical/Using_abstract_classes_2.java @@ -52,6 +52,12 @@ class Triangle extends TwoDShapes{ private String style; + public Triangle() { + // TODO Auto-generated constructor stub + super(); + style = "none"; + } + } From 8cd5b590274fa2a98b92bfcc2b65c03650d6e640 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:57:43 +0800 Subject: [PATCH 09/25] Committed on or around 2023/09/23 --- ..._super_to_call_superclass_constructor.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java new file mode 100644 index 0000000..610d3ae --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java @@ -0,0 +1,54 @@ +package theoretical; + +class TwoDShaper{ + + private double width; + private double height; + + public TwoDShaper(double w, double h) { + // TODO Auto-generated constructor stub + } + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + +} + + +class Triangular extends TwoDShaper{ + + private String style; + + public Triangular(String s, double w, double h) { + super(w, h); + + style = s; + } +} + +public class Using_super_to_call_superclass_constructor { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From 34756d5c07220c8d9671aa7f05c90ce9035baaa9 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 21:05:07 +0800 Subject: [PATCH 10/25] Committed on or around 2023/09/23 --- ..._super_to_call_superclass_constructor.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java index 610d3ae..e989511 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java @@ -42,12 +42,34 @@ public Triangular(String s, double w, double h) { style = s; } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } } public class Using_super_to_call_superclass_constructor { public static void main(String[] args) { - // TODO Auto-generated method stub + + Triangular t1 = new Triangular("filled", 4.0, 4.0); + Triangular t2 = new Triangular("outlined", 8.0, 12.0); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); } From 7449ce51583b16cc820535329a76354cdb0039c0 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 21:06:40 +0800 Subject: [PATCH 11/25] Committed on or around 2023/09/23 --- .../Using_super_to_call_superclass_constructor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java index e989511..9e3e923 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor.java @@ -70,6 +70,13 @@ public static void main(String[] args) { t2.showStyle(); t2.showDim(); System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); } From 673c26a772287f2e33972bae3a9f6678f306a6fb Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:50:10 +0800 Subject: [PATCH 12/25] Committed on or around 2023/09/23 --- ...uper_to_call_superclass_constructor_2.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java new file mode 100644 index 0000000..76a4bd4 --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java @@ -0,0 +1,63 @@ +package theoretical; + +import Cpp.this_keyword; + +class TwoDShaper_2{ + + private double width; + private double height; + private String title; + + public TwoDShaper_2(double w, double h) { + // TODO Auto-generated constructor stub + } + + public TwoDShaper_2() { + // TODO Auto-generated constructor stub + } + + TwoDShaper_2(double width, double height, String title){ + + this.width = width; + this.height = height; + this.title = title; + + } + + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + + String showTitle() { + return title; + } + +} + + +public class Using_super_to_call_superclass_constructor_2 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From 26bb2d0ab5d3ce114795f5ffc536b4ab5853fd47 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sat, 23 Sep 2023 23:55:35 +0800 Subject: [PATCH 13/25] Committed on or around 2023/09/23 --- .../Using_super_to_call_superclass_constructor_2.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java index 76a4bd4..169f252 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java @@ -53,6 +53,17 @@ String showTitle() { } +class Triangular_2 extends TwoDShaper_2{ + + private String style; + + public Triangular_2() { + // TODO Auto-generated constructor stub + } + +} + + public class Using_super_to_call_superclass_constructor_2 { public static void main(String[] args) { From 2a0483df3a73d0b2e7c7e9463b76fff3a361dd10 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:00:19 +0800 Subject: [PATCH 14/25] Committed on or around 2023/09/24 --- ...uper_to_call_superclass_constructor_2.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java index 169f252..3c8392e 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java @@ -61,6 +61,28 @@ public Triangular_2() { // TODO Auto-generated constructor stub } + public Triangular_2(String s, double w, double h) { + super(w, h); + + style = s; + } + + Triangular_2(String style, String title, double width, double height){ + + super(width, height, title); + + this.style = style; + + } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } + } From 7e4a4bf01452889820bd98b952089274d04585c3 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:01:10 +0800 Subject: [PATCH 15/25] Committed on or around 2023/09/24 --- .../Using_super_to_call_superclass_constructor_2.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java index 3c8392e..5ef913e 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java @@ -1,7 +1,5 @@ package theoretical; -import Cpp.this_keyword; - class TwoDShaper_2{ private double width; From 2781ec98ee1e84f487840672405a20273c3b987d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:11:51 +0800 Subject: [PATCH 16/25] Committed on or around 2023/09/24 --- ...uper_to_call_superclass_constructor_2.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java index 5ef913e..1efe849 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_2.java @@ -81,6 +81,12 @@ void showStyle() { System.out.println("Triangle is " + style); } + String showTitle() { + + return showTitle(); + + } + } @@ -88,7 +94,29 @@ public class Using_super_to_call_superclass_constructor_2 { public static void main(String[] args) { // TODO Auto-generated method stub - + Triangular_2 t1 = new Triangular_2("filled", 4.0, 4.0); + Triangular_2 t2 = new Triangular_2("outlined", 8.0, 12.0); + Triangular_2 t3 = new Triangular_2("Slovenly", "Classy", 8.0, 9.0); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t3: "); + t3.showStyle(); + t3.showDim(); + t3.showTitle(); + System.out.println("Area is " + t3.area()); } } From f503208fdf59f2392eb1c25e86bc269501eafb66 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:16:57 +0800 Subject: [PATCH 17/25] Committed on or around 2023/09/24 --- ...uper_to_call_superclass_constructor_3.java | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java new file mode 100644 index 0000000..7c06b92 --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java @@ -0,0 +1,103 @@ +package theoretical; + + +class TwoDShaper_3{ + + private double width; + private double height; + private String title; + + public TwoDShaper_3(double w, double h) { + // TODO Auto-generated constructor stub + } + + public TwoDShaper_3() { + // TODO Auto-generated constructor stub + } + + TwoDShaper_3(double width, double height, String title){ + + this.width = width; + this.height = height; + this.title = title; + + } + + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + + String showTitle() { + return title; + } + +} + + + +class Triangular_3 extends TwoDShaper_3{ + + private String style; + + public Triangular_3() { + // TODO Auto-generated constructor stub + } + + public Triangular_3(String s, double w, double h) { + super(w, h); + + style = s; + } + + Triangular_3(String style, String title, double width, double height){ + + super(width, height, title); + + this.style = style; + + } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } + + String showTheTitle() { + + return showTitle(); + + } + +} + + + +public class Using_super_to_call_superclass_constructor_3 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From c910642d24a97695f13d72e17c0ece2f3f1a719f Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Sun, 24 Sep 2023 00:18:33 +0800 Subject: [PATCH 18/25] Committed on or around 2023/09/24 --- ...uper_to_call_superclass_constructor_3.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java index 7c06b92..e974c2a 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_3.java @@ -97,6 +97,30 @@ public class Using_super_to_call_superclass_constructor_3 { public static void main(String[] args) { // TODO Auto-generated method stub + Triangular_3 t1 = new Triangular_3("filled", 4.0, 4.0); + Triangular_3 t2 = new Triangular_3("outlined", 8.0, 12.0); + Triangular_3 t3 = new Triangular_3("Slovenly", "Classy", 8.0, 9.0); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t3: "); + t3.showStyle(); + t3.showDim(); + t3.showTitle(); + t3.showTheTitle(); + System.out.println("Area is " + t3.area()); } From 0414f837a12c9aca7994af8fd9a28900980b2b80 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:51:39 +0800 Subject: [PATCH 19/25] Committed on or around 2023/09/25 --- ...uper_to_call_superclass_constructor_4.java | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java new file mode 100644 index 0000000..16224c3 --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java @@ -0,0 +1,133 @@ +package theoretical; + + +class TwoDShaper_4{ + + private double width; + private double height; + private String title; + + public TwoDShaper_4(double w, double h) { + // TODO Auto-generated constructor stub + } + + public TwoDShaper_4() { + // TODO Auto-generated constructor stub + } + + TwoDShaper_4(double width, double height, String title){ + + this.width = width; + this.height = height; + this.title = title; + + } + + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + + String showTitle() { + return title; + } + +} + + +class Triangular_4 extends TwoDShaper_3{ + + private String style; + + public Triangular_4() { + // TODO Auto-generated constructor stub + } + + public Triangular_4(String s, double w, double h) { + super(w, h); + + style = s; + } + + Triangular_4(String style, String title, double width, double height){ + + super(width, height, title); + + this.style = style; + + } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } + + String showTheTitle() { + + return showTitle(); + + } + +} + + + +public class Using_super_to_call_superclass_constructor_4 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Triangular_4 t0 = new Triangular_4(); + Triangular_4 t1 = new Triangular_4("filled", 4.0, 4.0); + Triangular_4 t2 = new Triangular_4("outlined", 8.0, 12.0); + Triangular_4 t3 = new Triangular_4("Slovenly", "Classy", 8.0, 9.0); + + System.out.println("Info for t0: "); + t0.showStyle(); + t0.showDim(); + System.out.println("Area is " + t0.area()); + + System.out.println(); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t3: "); + t3.showStyle(); + t3.showDim(); + t3.showTitle(); + t3.showTheTitle(); + System.out.println("Area is " + t3.area()); + } + +} From 2194b0ab9a8e9576f6731dfb7a83cb0758c3430d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:57:20 +0800 Subject: [PATCH 20/25] Committed on or around 2023/09/25 --- .../Using_super_to_call_superclass_constructor_4.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java index 16224c3..d01a16a 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java @@ -103,6 +103,8 @@ public static void main(String[] args) { System.out.println("Info for t0: "); t0.showStyle(); + t0.setHeight(9); + t0.setWidth(3); t0.showDim(); System.out.println("Area is " + t0.area()); From d61a6bc8411f06ac94a45687d151ecb6963d458a Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:07:40 +0800 Subject: [PATCH 21/25] Committed on or around 2023/09/25 --- .../Using_super_to_call_superclass_constructor_4.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java index d01a16a..232cad7 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java @@ -52,7 +52,7 @@ String showTitle() { } -class Triangular_4 extends TwoDShaper_3{ +class Triangular_4 extends TwoDShaper_4{ private String style; From 28f88a7cfd6d70d49d0a9e1286be82f8d5d9d106 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:09:14 +0800 Subject: [PATCH 22/25] Committed on or around 2023/09/25 --- .../Using_super_to_call_superclass_constructor_4.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java index 232cad7..1509910 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java @@ -8,7 +8,8 @@ class TwoDShaper_4{ private String title; public TwoDShaper_4(double w, double h) { - // TODO Auto-generated constructor stub + width = w; + height = h; } public TwoDShaper_4() { From 9ee09dfdf9b1eb951aec44deaad306d45db930d2 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:11:52 +0800 Subject: [PATCH 23/25] Committed on or around 2023/09/25 --- .../Using_super_to_call_superclass_constructor_4.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java index 1509910..e58cc11 100644 --- a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_4.java @@ -107,6 +107,8 @@ public static void main(String[] args) { t0.setHeight(9); t0.setWidth(3); t0.showDim(); + t0.showTitle(); + t0.showTheTitle(); System.out.println("Area is " + t0.area()); System.out.println(); From 46d42ee98b577a0c0923c77a3d9aa1743552f9c4 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:32:10 +0800 Subject: [PATCH 24/25] Committed on or around 2023/09/25 --- ...uper_to_call_superclass_constructor_5.java | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor_5.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_5.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_5.java new file mode 100644 index 0000000..99fdeae --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_5.java @@ -0,0 +1,144 @@ +package theoretical; + +class TwoDShaper_5{ + + private double width; + private double height; + String title; + + public TwoDShaper_5(double w, double h) { + width = w; + height = h; + } + + public TwoDShaper_5() { + // TODO Auto-generated constructor stub + } + + TwoDShaper_5(double width, double height, String title){ + + this.width = width; + this.height = height; + this.title = title; + + } + + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + + String showTitle() { + return title; + } + + void showTitle_2() { + System.out.println("Triangle is also " + title); + } + +} + + +class Triangular_5 extends TwoDShaper_5{ + + private String style; + + public Triangular_5() { + // TODO Auto-generated constructor stub + } + + public Triangular_5(String s, double w, double h) { + super(w, h); + + style = s; + } + + Triangular_5(String style, String title, double width, double height){ + + super(width, height, title); + + this.style = style; + + } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } + + String showTheTitle() { + + return showTitle(); + + } + + void showTheTitle_2() { + System.out.println("Triangle is also " + super.title); + } + +} + + +public class Using_super_to_call_superclass_constructor_5 { + + public static void main(String[] args) { + Triangular_5 t0 = new Triangular_5(); + Triangular_5 t1 = new Triangular_5("filled", 4.0, 4.0); + Triangular_5 t2 = new Triangular_5("outlined", 8.0, 12.0); + Triangular_5 t3 = new Triangular_5("Slovenly", "Classy", 8.0, 9.0); + + System.out.println("Info for t0: "); + t0.showStyle(); + t0.setHeight(9); + t0.setWidth(3); + t0.showDim(); + t0.showTitle(); + t0.showTheTitle(); + System.out.println("Area is " + t0.area()); + + System.out.println(); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t3: "); + t3.showStyle(); + t3.showDim(); + t3.showTitle_2(); + t3.showTheTitle_2(); + System.out.println("Area is " + t3.area()); + + } + +} From 83e66823f8a8ef1f466e939b0b98c51be4538a2d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:43:39 +0800 Subject: [PATCH 25/25] Committed on or around 2023/09/25 --- ...uper_to_call_superclass_constructor_6.java | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 Chapter7/theoretical/Using_super_to_call_superclass_constructor_6.java diff --git a/Chapter7/theoretical/Using_super_to_call_superclass_constructor_6.java b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_6.java new file mode 100644 index 0000000..a0f932b --- /dev/null +++ b/Chapter7/theoretical/Using_super_to_call_superclass_constructor_6.java @@ -0,0 +1,151 @@ +package theoretical; + + +class TwoDShaper_6{ + + private double width; + private double height; + String title; + + public TwoDShaper_6(double w, double h) { + width = w; + height = h; + } + + public TwoDShaper_6() { + // TODO Auto-generated constructor stub + } + + TwoDShaper_6(double width, double height, String title){ + + this.width = width; + this.height = height; + this.title = title; + + } + + + double getWidth() { + return width; + } + + double getHeight() { + return height; + } + + void setWidth(double w) { + width = w; + } + + void setHeight(double h) { + height = h; + } + + void showDim() { + + System.out.println("Width and height are " + width + " and " + height); + } + + String showTitle() { + return title; + } + + void showTitle_2() { + System.out.println("Triangle is also " + title); + } + +} + + +class Triangular_6 extends TwoDShaper_6{ + + private String style; + + public Triangular_6() { + // TODO Auto-generated constructor stub + } + + public Triangular_6(String s, double w, double h) { + super(w, h); + + style = s; + } + + Triangular_6(String style, String title, double width, double height){ + + super(width, height, title); + + this.style = style; + + } + + double area() { + return getWidth() * getHeight() / 2; + } + + void showStyle() { + System.out.println("Triangle is " + style); + } + + String showTheTitle() { + + return showTitle(); + + } + + void showTheTitle_2() { + System.out.println("Triangle is also " + super.title); // super is redundant here. + } + + void showTheTitle_3() { + System.out.println("Triangle is also " + title); + } + +} + + +public class Using_super_to_call_superclass_constructor_6 { + + public static void main(String[] args) { + + Triangular_6 t0 = new Triangular_6(); + Triangular_6 t1 = new Triangular_6("filled", 4.0, 4.0); + Triangular_6 t2 = new Triangular_6("outlined", 8.0, 12.0); + Triangular_6 t3 = new Triangular_6("Slovenly", "Classy", 8.0, 9.0); + + System.out.println("Info for t0: "); + t0.showStyle(); + t0.setHeight(9); + t0.setWidth(3); + t0.showDim(); + t0.showTitle(); + t0.showTheTitle(); + System.out.println("Area is " + t0.area()); + + System.out.println(); + + System.out.println("Info for t1: "); + t1.showStyle(); + t1.showDim(); + System.out.println("Area is " + t1.area()); + + System.out.println(); + + System.out.println("Info for t2: "); + t2.showStyle(); + t2.showDim(); + System.out.println("Area is " + t2.area()); + + System.out.println(); + + System.out.println("Info for t3: "); + t3.showStyle(); + t3.showDim(); + t3.showTitle_2(); + t3.showTheTitle_2(); + t3.showTheTitle_3(); + System.out.println("Area is " + t3.area()); + + } + +}