diff options
author | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-24 16:44:31 +0000 |
---|---|---|
committer | Sudipto Mallick <smlckz@termux-alpine> | 2024-01-24 16:44:31 +0000 |
commit | 6766b6479a1d30680c1eb59df4c4b720eb22ce1c (patch) | |
tree | 19af8079fbed64732f891da09c69356153cc0170 /java/text | |
parent | 8fb719f58f91d1f1f187a1db974682fb3736ee05 (diff) | |
download | zadania-6766b6479a1d30680c1eb59df4c4b720eb22ce1c.tar.gz |
Implement Java Assignment #15 and more
java/{code/ParentWithTwoChildren.java, output/ParentWithTwoChildren.typ, text/ParentWithTwoChildren.typ}: Code, output and assignment text for Java assignment #15 java/state.sql: Update for Java assignment #15 java/template.typ: Allow for long program description to be left aligned and justified, instead of centered java/tobedone: Update to show assignment numbers (implicitly `rowid`)
Diffstat (limited to 'java/text')
-rw-r--r-- | java/text/ParentWithTwoChildren.typ | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/java/text/ParentWithTwoChildren.typ b/java/text/ParentWithTwoChildren.typ new file mode 100644 index 0000000..e307cc8 --- /dev/null +++ b/java/text/ParentWithTwoChildren.typ @@ -0,0 +1,28 @@ +#import "/template.typ": * +#show: A => apply(A) +#set raw(lang: "java-new") +#set par(leading: 0.5em) + +#assignment(15, block: true)[ + Write a program to create a class `Parent` having instance variables `id`, `name` and `address`; a class `ChildOne` having instance variables `id`, `name`, `address` and `marks`; another class `ChildTwo` with instance variables `id`, `name`, `address`, `qualification` and `salary`. Design the program using `super` call with proper parameters within each class and define your own method to display values of the member variable and use an object of each class from `main()` to display their properties. +] + +#scos("ParentWithTwoChildren") + +=== Discussion + +#skind[Classes, interfaces and methods used from Java standard library] + +- `java.lang.Object` class: + - `Class<?> getClass()`: Returns the `Class` object representing the class of the object. +- `java.lang.Class<T>` class: + - `String getSimpleName()`: Returns the simple name of the underlying class as a string. + +#skind[Classes and methods implemented in the program] + +- `Parent`: Base class with `id`, `name`, and `address`, displaying all information dynamically using the `display` method. +- `ChildOne`: Inherits from `Parent`, adds `marks`, and displays them after parent data using the `display` method. +- `ChildTwo`: Inherits from `Parent`, adds `qualification` and `salary`, and displays them after parent data using the `display` method. +- `Main`: Creates and showcases `Parent`, `ChildOne`, and `ChildTwo` object details using the `main` method. + +#signature() |