Landing : Athabascau University

Reflections on Assignment 2.: Revision

Last updated January 5, 2024 - 5:17am by Joan Oladunjoye

Assignment 2 Reflection:

Project 1: Animals and their Respective Sounds:

Files linked with this project: Main.java and AnimalTest.java.

This challenge question is mapped to the following learning objectives:

  •      articulate the principles of object-oriented problem solving and programming.
  •      outline the essential features and elements of the Java programming language.
  •      explain programming fundamentals, including statement and control flow and recursion.
  •      apply the concepts of class, method, constructor, instance, data abstraction, function abstraction, inheritance, overriding, overloading, and polymorphism.
  •      program with basic data structures using array, list, and linked structures.
  •      explain the object-oriented design process and the concept of software engineering.
  •      program using objects and data abstraction, class, and methods in function abstraction.
  •      analyze, write, debug, and test basic Java codes using the approaches introduced in the course.
  •      analyze problems and implement simple Java applications using an object-oriented software engineering approach.

This programming challenge question was completed by creating two classes Main.java and AnimalTest.java.  Both of these classes were created in two separate files saved in the same folder. As with all Java files created, the both file names are the same as the class names created.

This project demonstrates the concepts of class, inheritance, polymorphism and method overriding.

It required the use of extended classes in the Main class as was directed in the assignment brief.  This ultimately allowed for individual animal classes to be created. Examples of classes created includes the pig, sheep, duck and cow classes. These classes take over all attributes, methods and constructors of the main class.  This is because they are extended classes and are used to add functionality to these subclasses. In a nutshell, the animal class is a super class with four subclasses.

In this project brief, since Pig (and all other named animal classes i.e. sheep, duck & cow) are subclasses of the class Animalan object of type Pig contains all the instance variables and instance methods defined in Animal. Variables and methods from the Animal class are inherited by Pig, and they can be used in the definition of Pig just as if they were actually defined in that class—except for any that are declared to be private, which prevents access even by subclasses.

The AnimalTest class is a separate class from the Main class with its own main method and they operate separately, and are intended to be run independently with no direct linkage existing between them. The AnimalTest class allows one to create an instance of an animal based on a command line argument and then invoke the sound method of that animal.

In order to use the Animal hierarchy in the AnimalTest class, I had to create an instance of an animal class by invoking its methods just like was done in the Main class.

In summary, the solution to challenge problem 1 can be outlined thus: In the Main class, instances of each animal are created, and their sound() methods are called to demonstrate different sounds.

In the AnimalTest class, command line arguments are used to determine the type of animal to create, and then thesound() method of the corresponding animal is called. This allows dynamic instantiation and method invocation based on user input.  Dynamic instantiation involves creating objects at runtime, and method invocation involves calling the methods associated with objects to perform specific actions or computations. These concepts are fundamental in object-oriented programming paradigms.

This program can only be run via terminal if using Mac.

In order to get the required output for the program, that file called ‘AnimalTest.java should be run by specifying each of the animals in the subclass within the class Animal.  Eg. 'java AnimalTest Pig'

Do note that 'AnimalTest.java' will compile without errors ONLY when 'Main.java' has been successfully compiled. This is in other for the interface implementation between both files to occur.

Some key things I learnt while working on this challenge question:

The Main method: I wondered why most examples that I reviewed online had the Main method below their animal subclasses, e.g. Pig, Sheep, Duck, and Cow as subclasses of the class ‘Animal’ and found out that this was so as to ensure readability and logic flow.  Personally, I would have preferred to have my Main class at the top of the program if I had not reviewed some examples linked with this question that demonstrates the principles of inheritance, polymorphism, and method overriding in Java.

The sound method: When the sound method is called on each animal instance, polymorphism comes into play, and the overridden sound method of the specific animal type is executed. It should be noted that this project mainly involves polymorphism and method overriding.

In summary, this project demonstrates an example of class, hierarchy, inheritance, and polymorphism through method overriding.  The ‘Animal’ class is used as the base class, and the subclasses – pig, sheep, duck and cow show polymorphic behaviour by providing their own implementation of the sound method.

Project Overview:

The Main Class.

The aim of this code is to demonstrate the principles of inheritance, polymorphism & method overriding in Java. In this program, two classes are created in separate files named,'The Main class & 'The AnimalTest Class'. 

The 'Main Class stores the 'Animal class which is the base class with a defaultconstructor (a default constructor is on with no parameters e.g. ‘public Animal()’)and a sound method.  'Pig','Sheep','Duck’, & 'Cow' are subclasses of 'Animal'. Each subclass overrides the sound method to provide a specific sound for that animal. Also, in the main method, instances of each animal type (Pig, Sheep, Duck, Cow) are created and assigned to variables of type Animal. This demonstrates polymorphism, where objects of a superclass type (Animal) can refer to objects of its subclasses.

The AnimalTest Class

The aim of this code is to demonstrate the principles of inheritance, polymorphism & method overriding in Java. In this program, two classes are created in separate files named,’ The Main class & 'The AnimalTest class'. The 'Animal Test class, reads the command line user input and creates

the appropriate Animal child class based on the type of animal, it then calls the animal's sound() method.

This program is run via terminal if using a Mac OS or via Command Prompt or PowerShell if using Windows OS. This is done using the 'javac' & 'java ‘keywords to compile and run ie

'javac AnimalTest.java' to compile & 'java AnimalTest Pig' to run. (Pig can be replaced with 'Sheep’, ‘Duck', or 'Cow’) It should be noted that this program works in collaboration with the programentitled Main.java and that required output can be obtained by compiling and running AnimalTest.java

Test Plan

A test plan outlines the testing approach, scope, resources, and schedule for testing. In this case, I'll provide a simplified test plan for both the ‘Main’ & ‘AnimalTest’ classes.

A good test plan typically includes normal, borderline/boundary, and extreme test cases 

Test Plan for Main.java

Since the Main class primarily involves polymorphism and method overriding, I will focus on testing the behavior of the sound method.

  1. Normal Test: Verifies Sound of all subclasses. I.e. Pig, Sheep, Duck & Cow

Test 1:

Input: None (using default constructor)

Expected Output:

I am an animal.
I am a pig.
I am an animal.
I am a sheep.
I am an animal.
I am a duck.
I am an animal.
I am a cow.
Pig says "oink"
Sheep says "baah"
Duck says "quack"
Cow says "moo"

2. Borderline/Boundary Test: Verifies Polymorphism with Animal Reference of all subclasses. I.e. Pig, Sheep, Duck & Cow.  Will use the instantiation of an object of a class named ‘Pig’ as example.  Same test applies to all subclasses.

Test 2:

Input: Animal cat = new Pig();//cat could be replaced with any animal

Expected Output:

I am an animal.
I am a pig.
I am an animal.
I am a sheep.
I am an animal.
I am a duck.
I am an animal.
I am a cow.
Pig says "oink"
Sheep says "baah"
Duck says "quack"
Cow says "moo"

Explanation: This test explores polymorphism by assigning an object of the Pig class to a variable of type Animal. It's on the borderline because it tests if the polymorphic behavior is correctly handled, allowing an object of the subclass to be treated as an object of the superclass.

3.  Extreme Test Cases:

Test 3: Verify Behavior with Null Object

Input: Large number of instances created within Main class i.e. two additional instances added.

Animal cat = new Cat();
Animal dog = new Dog()

Expected Output:
I am an animal.
I am a pig.
I am an animal.
I am a sheep.
I am an animal.
I am a duck.
I am an animal.
I am a cow.
Pig says "oink"
Sheep says "baah"
Duck says "quack"
Cow says "moo"

Test Plan for AnimalTest.java

  1. Normal Test:

Test 1: Program tested with valid animal types: in this case 'cow'. e.g. 'java AnimalTest Cow'

Expected Output:
I am an animal.
I am a cow.
Cow says "moo"Borderline/Boundary Test:

2. Borderline Test : 

Multiple Command-Line Arguments: Test the program with multiple command-line arguments to ensure it only considers the first one. e. g ‘java AnimalTest Pig Sheep Duck Cow’

Expected Output:
I am an animal.
I am a pig.
Pig says "oink"

 3. Extreme:

Test 3: Empty Command-Line Arguments: Test the program with an empty array of command-line arguments. e.g. 'java AnimalTest'

Expected Output:

Please provide the type of animal as a command line argument.

References: 

  1. Eck, David J. "Introduction to Programming Using Java (Version 8.1)." July 2019. Accessed 5th December 2023.
  2. Geekforgeek. "Command Line Arguments in Java." https://www.geeksforgeeks.org/command-line-arguments-in-java/. Accessed 20th December 2023. 
  3. Hellas Arto, Luukkainen Matti. "IntelliJ Setup: Object-Oriented Programming with Java, part I + II." https://hhs-2018-se-dt-s2-apip.github.io/APDE-lesmateriaal/week9. Accessed 25th December 2023.
  4. W3resource. "Java Inheritance Programming - Animal with a method called makeSound." https://www.w3resource.com/java-exercises/java-inheritance-exercise-1.php. Accessed 25th December 2023.
  5. W3schools. "Java Polymorphism." https://www.w3schools.com/java/showjava.asp?filename=demo_polymorphism. Accessed 25th December 2023

Assignment 2 Reflection:

Problem 2: Book Class for Representing and Testing Book Objects.

Files linked with this project: Book.java and TestBook.java.

This challenge question is mapped to the following learning objectives:

  •  articulate the principles of object-oriented problem solving and programming.
  •  outline the essential features and elements of the Java programming language.
  •  explain programming fundamentals, including statement and control flow and recursion.
  •  apply the concepts of class, method, constructor, instance, data abstraction, function abstraction, inheritance, overriding, overloading, and polymorphism.
  •  program with basic data structures using array, list, and linked structures.
  •  explain the object-oriented design process and the concept of software engineering.
  •   program using objects and data abstraction, class, and methods in function abstraction.
  •   analyze, write, debug, and test basic Java codes using the approaches introduced in the course.
  •   analyze problems and implement simple Java applications using an object-oriented software engineering approach.

This project had been created using two classes namely ‘Book.java’ and ‘TestBook.java’. 

The Book Class:

This Book class represents a book with various attributes such as title, ISBN number, author, edition, publisher, and year of publication. 

The code demonstrates encapsulation by making these attributes private and providing 

public getter and setter methods to access and modify them. Additionally, the ‘Book’ class has a constructor that allows the creation of a ‘Book’ object with specified attribute values.  This provides a way for the program to initialise the object when created.

The TestBook Class:

This class serves as a testing environment to ensure that the Book class functions as expected, both for manually created instances and for a more extensive set of dynamically generated instances in an extreme testing scenario.

The problem brief does not require that any input validation or immutability checks (i.e. this means that the state of an instance cannot be changed once it has been created) be applied to any of its attributes so this has not been carried out while solving this challenge problem. 

In order to have books displayed to console, the file ‘Book.java’ will need to be compiled first before the ‘TestBook.java’ file is compiled and run.  This is because the ‘TestBook’ file depends on the ‘Book’ file for creating objects and accessing their attributes. The ‘TestBook’ file uses the functionality provided by the ‘Book’.

In a nutshell, the ‘Book’ class encapsulates data and methods in a single unit called a class. The properties and behaviours related to books, and the ‘TestBook’ class interacts with one another to perform specific operations bearing in mind that encapsulation, is to make sure that "sensitive" data is hidden from users. These sensitive data if needed can be accessed using the ‘getter’ – ‘setter’. methods.

Test Plan for Book & TestBook .java 

 1. Normal Test:

Creating a book with standard attributes.

Test Steps:

  • I created a new Book object with typical values for title, ISBN, author, edition, publisher, and year.
  • I used getter methods to retrieve each attribute.
  • I verified that the retrieved values match the initially set values.
  • The ‘TestBook class’ demonstrates the normal test scenario you've outlined. It creates five instances of the Book class with different attribute values and then uses the getter methods to display the information for each book.

     Expected Output:

javac Book.java
javac TestBook.java
java TestBook

Book 1:
Title: Learn Java in one day
ISBN: 9781790789870
Author: Jamie Chan
Edition: Fourth Edition
Publisher: Amazon
Year: 2018

Book 2:
Title: Python Tricks: The Book
ISBN: 9781775093305
Author: Dan Bader
Edition: First Edition
Publisher: Amazon
Year: 2019

Book 3:
Title: C# Programming
ISBN: 978-1-84078-906-5
Author: Mike McGrath
Edition: 2nd Edition
Publisher: In Easy Steps
Year: 2020
 
Book 4:
Title: C# For Beginners
ISBN: 9781981070527
Author: Nathan Metzler
Edition: First Edition
Publisher: Amazon
Year: 2019
 
Book 5:
Title: Python Challenge!
ISBN: 9781910523353
Author: PM Heathcote
Edition: First Edition
Publisher: PG Online
Year: 2021

     Borderline Test:

Modify book attributes using setter methods. 

Test Steps:

  • The TestBook class already has five new Book objects created with initial values set.
  • To carryout borderline testing on these, I will be using only book 1 for my testing. I used the setter method to modify each attribute of Book 1.
  •  I then verified that the retrieved values matched the modified values.  See expected output below.

     Expected Output:

javac Book.java
javac TestBook.java
java TestBook
 
Book 1: Original Entry
Title: Learn Java in one day
ISBN: 9781790789870
Author: Jamie Chan
Edition: Fourth Edition
Publisher: Amazon
Year: 2018
 
Modified Book 1:
Title: Reading and Writing about Literature
ISBN: 978-1-319-03536-5
Author: Janet E. Gardner & Joanne Diaz
Edition: Fourth Edition
Publisher: Macmillan Learning
Year: 2004
 
 Output for book 2 – 5 remained the same as with normal testing upon running program as no modifications was carried out on them.

     Extreme Test:

Create and display a large number of books. 

     Test Steps:

  • Create an array or collection of Book objects with a significant number (e.g., 150 or more). 
  • Use a loop to iterate through the collection and display the information for each book using the displayBookInfo method. 
  • Verify that the information for each book is displayed correctly without errors. 

     Test to help verify that the code created for the purpose of extreme testing can handle a large number of books without facing errors or performance i 

     Since the TestBook.java file is dependent on the Book.java file, all testing carried out are linked to both files.

References: 

  1. Eck, David J. "Introduction to Programming Using Java (Version 8.1)."July 2019. Accessed 20th December 2023. 
  2. W3resource. " Java: Create and Modify Dog Objects." https://www.w3resource.com/java-exercises/oop/java-oop-exercise-2.php.Accessed  27th December 2023.
  3. W3Schools. "Java Constructors." https://www.w3schools.com/java/java_constructors.asp. Accessed 25th December 2023.
  4. W3Schools. "Java Encapsulation." https://www.w3schools.com/java/java_encapsulation.asp. Accessed 25th December 2023. 
  5. W3Schools. "Java private Keyword." https://www.w3schools.com/java/ref_keyword_private.asp. Accessed 25th December 2023.
  6. W3Schools. "Java Methods." https://www.w3schools.com/java/java_methods.asp. Accessed 25th December 2023. 

Assignment 3 Reflection:

Problem 3: An Introduction to Computer Programming

Elevator Simulation and Testing Challenge.

Files linked with this project: Elevator.java and ElevatorTest.java.

This challenge question is mapped to the following learning objectives:

  •      articulate the principles of object-oriented problem solving and programming.
  •      outline the essential features and elements of the Java programming language.
  •      explain programming fundamentals, including statement and control flow and recursion.
  •      apply the concepts of class, method, constructor, instance, data abstraction, function abstraction, inheritance, overriding, overloading, and polymorphism.
  •      program with basic data structures using array, list, and linked structures.
  •      explain the object-oriented design process and the concept of software engineering.
  •      program using objects and data abstraction, class, and methods in function abstraction.
  •      analyze, write, debug, and test basic Java codes using the approaches introduced in the course.
  •      analyze problems and implement simple Java applications using an object-oriented software engineering approach.

I received the inspiration and necessary guidelines to start off this challenge problem by reading the reflection of another student @ Yuyang Liu's via his comments on the landing - https://landing.athabascau.ca/pages/view/16156140/assignment2. Accessed 28th December 2023. 

This program is made up of two files.  One of the files defines a class called ‘Elevator’.  This class has two constructors, one of these is a default constructor that initializes number of floors to 5.  This class also has another constructor that allows one to specify the number of floors when creating an object. Within this class is a cleanup method that sets the elevator to the first floor.  The goToFloor method allows the elevator to move to specified floors with appropriate messages printed for different scenarios that are tested.

The second class that this challenge question is made up of is the ElevatorTest class. This class was set up to test various scenarios (up to five in total), including using the default constructor, using a specified number of floors, attempting to go to an invalid floor, testing when the elevator is already on the requested floor, and testing the cleanup method.

One of the challenges that I encountered with this question was that the finalize method did not work with my code. Upon research I found out that this method has been deprecated in recent Java versions (Source: - InfoWorld) So, it has not been explicitly implemented in the solution to this challenge question. Instead, the code uses a cleanup method that is explicitly called in the test scenarios.

In my code I after using each elevator instance, I added a line to set the reference to ‘null’.  I however found that that doing this does not directly trigger garbage collection because Java garbage collection will automatically reclaim memory where there are no more references to an object. For the purposes of this project, I still preferred to leave that line of code in my ElevatorTest class.

In summary for this project, the Elevator class encapsulates elevator functionality, including movement between floors and cleanup while the ElevatorTest class provides scenarios to test different aspects of the elevator class, covering constructors, floor movements, error handling, and cleanup procedures.

Test Plan for Elevator & ElevatorTest .java

     Normal Test:

  • Created an elevator using the default constructor.
  • Expected Output: Elevator initialized with 5 floors, starting at floor 1.

     Borderline Test:

  • Attempted to move the elevator to an invalid floor.
  • Expected Output: Display an error message and do not change the current floor.

     Extreme Test:

  • Created an elevator with the maximum allowed number of floors.
  • This assumes the ‘elevator’ class allows for a maximum number of floors.   An instance of the elevator with maximum allowed number of floors is created and operations performed on it.
  • Expected Output: Elevator initialized with the maximum number of floors, starting at floor 1.

References: 

  1. Eck, David J. "Introduction to Programming Using Java (Version 8.1).July 2019. Accessed 26th December 2023 
  2. Ramuglia Gabriel. Ioflood blog. https://ioflood.com/blog/default-constructor-java/. Accessed 26th December 2023.
  3. Stack Overflow. Elevator Program. https://codereview.stackexchange.com/questions/7990/elevator-program. Accessed 26th December 2023.
  4. Srivastava Ankit Kumar. Designing Elevator Algorithms in Java Using Object-Oriented Principles. https://medium.com/@ankitviddya/designing-elevator-algorithms-in-java-using-object-oriented-principles-359588871867
  5. Tyson Matthew. InfoWorld: https://www.infoworld.com/article/3649089/how-to-handle-java-errors-and-cleanup-without-finalize.html#:~:text=Java%27s%20finalize%20method%20will%20be,Let%27s%20look%20at%20the%20alternatives.&text=After%20several%20years%20of%20rumblings,finalize%20method%20in%20JDK%2018.Accessed 29th December 2023
  6. Yuyang Liu's via his comments on the landing - https://landing.athabascau.ca/pages/view/16156140/assignment2. Accessed 28th December 2023.

Assignment 4 Reflection:

Problem 4: An Introduction to Computer Programming
Rodent World: Creating and Inheritance Hierarchy in Java 

Files linked with this project: RodentTest.java.

This challenge question is mapped to the following learning objectives:

  •      articulate the principles of object-oriented problem solving and programming.
  •      outline the essential features and elements of the Java programming language.
  •      explain programming fundamentals, including statement and control flow and recursion.
  •      apply the concepts of class, method, constructor, instance, data abstraction, function abstraction, inheritance, overriding, overloading, and polymorphism.
  •      program with basic data structures using array, list, and linked structures.
  •      explain the object-oriented design process and the concept of software engineering.
  •      program using objects and data abstraction, class, and methods in function abstraction.
  •      analyze, write, debug, and test basic Java codes using the approaches introduced in the course.
  •      analyze problems and implement simple Java applications using an object-oriented software engineering approach.

In this program I created an inheritance hierarchy of Rodent: mouse, gerbil, hamster, guinea pig.  Methods were then provided in the base class that are common to all rodents based on their various behaviours.  Each behaviour prints its action to standard output. The various behaviours used for this challenge problem were accessed from the links provided in the reference section below.

Part of this program involves refining these behaviours in the child classes to perform different behaviours, depending on the specific type of rodent, but only if the behaviour is actually different (e.g., mouse is nibbling on cheese or gerbil is digging tunnel). 

Finally the main() class was defined , and instances of every rodent, that displays all the behaviours for each rodent were then created. This concept of creating instances of every rodent created demonstrates polymorphism,where instances of the child classes can be treated as instances of the base class. Finally, Rodent classes were then tested.  This process of testing again demonstrated polymorphic behavior where the overridden methods in the child classes are executed based on the actual runtime type of the object.

In summary, this code includes inheritance, polymorphism, and method overriding, and it models a simple hierarchy of rodents with specific behaviors for each type. It also provides a mechanism to test and demonstrate these behaviors in the main method of the RodentTest class.

Test Plan for Rodent World – RodentTest.java

Normal Testing: 

  • Create Rodent Instances: Instances of each type of rodent (Mouse, Gerbil, Hamster, GuineaPig) were created as instructed in project brief.  For normal testing, it was verified that the common behaviors work as expected.

Borderline Testing.

  • Empty Rodent Creation: I created an instance of the ‘Rodent’ class and verified that the default behaviours are invoked.

Extreme Testing: 

  • Invalid Subclass Creation: An example extreme testing for this program could be attempting to create instances that are not part of the Rodent hierarchy and verifying that the program handles it well.   

Expected Output: A message will be displayed that reads: Cannot test behaviors. Object is not a Rodent.

References: 

  1. Bro Code. Java Inheritance. https://youtu.be/Zs342ePFvRI. Accessed 31st December 2023
  2. Eck, David J. "Introduction to Programming Using Java (Version 8.1)."July 2019. Accessed 30th December 2023.
  3. Jones Lauren. 10 Pet Rat Behaviours and What They Mean. https://www.petmd.com/exotic/10-pet-rat-behaviors-and-what-they-mean. Accessed 1st January 2024.
  4. Lafeber Company. https://lafeber.com/mammals/16-common-pet-rat-behaviors/. Accessed 1st January 2024.  

Assignment 5 Reflection:

Problem 5: An Introduction to Computer Programming
Java Geometry Models Project 

Files linked with this project: CustomPoint.java, Shape.java, Rectangle.java, Circle.java Triangle.java & PointMain.java.

This challenge question is mapped to the following learning objectives:

  •      articulate the principles of object-oriented problem solving and programming.
  •      outline the essential features and elements of the Java programming language.
  •      explain programming fundamentals, including statement and control flow and recursion.
  •      apply the concepts of class, method, constructor, instance, data abstraction, function abstraction, inheritance, overriding, overloading, and polymorphism.
  •      program with basic data structures using array, list, and linked structures.
  •      explain the object-oriented design process and the concept of software engineering.
  •      program using objects and data abstraction, class, and methods in function abstraction.
  •      analyze, write, debug, and test basic Java codes using the approaches introduced in the course.
  •      analyze problems and implement simple Java applications using an object-oriented software engineering approach.

In tackling the Java Geometry Models Project, I encountered a profound and multifaceted challenge that not only expanded my grasp of object-oriented problem-solving but also deepened my understanding of Java programming. The project aligns with various learning objectives, covering essential features of the Java language and emphasizing key programming fundamentals.

The initial stages of creating this project was simple enough until it came to the geometric calculations that needed to be done in order to ensure that the program ran the way it was meant to.  I will say that by far this is the most challenging project I have encountered so far.  The holistic project required six classes in all were created.  

The first class was the Point class and this class held x and y values for a point and it had the following methods - show(), add() and subtract(). These classes were created to display the Point x and y values, and add and subtract point coordinates respectively. It served as the foundational element of this project.  One of the things I did not realize at the onset of this project is that the word ‘Point’ is actually a reserved word/ a class in java. So, at the onset of this project my file name was called ‘Point.java’.  This had to be altered because when it came to testing my final project, some methods such as the show() method from the import statement java.awt.Point could not be accessed because there was a point class conflict of some sorts.

Next a superclass Shape.java was created and this class was used to represent a generic geometric shape with a 'bounding box' defined by two 'CustomPoint' objects x-y.

Afterwards the rectangle class was created.  This class was an extension of the shape class. 
It adds an array of vertices and a Boolean flag indicating whether the rectangle is a square and 
overrides the display method to include information about the rectangles vertices and whether it is a square.

The Triangle class created also extended the shape class to represent a triangle.  It used the point class objects as vertices and overrode the display method to include information about the triangle vertices.  Additionally, it contained methods for validating a triangle and finding the top-left and bottom-right points for the bounding box.

 

Next, was the circle class. class extended the shape class to represent a circle.  It included

private variables for the center point class and the radius. Override methods were used to calculate the area and circumference of the circle. 

The final component created was the main class. This file was used to demonstrate the creation of instances of all shapes created in this project so that their information could be displayed to console as desired. 

In conclusion, this project provided a rich learning experience encompassing object-oriented programming, inheritance, polymorphism, encapsulation, exception handling, static methods, composition, method overriding, and conditional statements. It not only enhanced my ability to design and implement solutions but also underscored the significance of these programming concepts in addressing complex problems using Java.

Test Plan for Geometry Project – PointMain.java

Normal:

  • I ran file and ensured that all relevant information were displayed as required.

Borderline: 

  • I created invalid triangle method and ensured that program handled error using relevant exception rule.

Extreme:

  • I tested application using invalid inputs, such as null values to make sure that this was handled gracefully by program.

References:

  1. Dive Into Deep Learning. https://d2l.djl.ai/chapter_computer-vision/bounding-box.html#:~:text=The%20bounding%20box%20is%20a,right%20corner%20of%20the%20rectangle. Accessed 3rd January 2024.
  2. Eck, David J. "Introduction to Programming Using Java (Version 8.1)."July 2019. Accessed 1st January 2023.
  3. Neso Academy. Introduction to Classes and Objects (Part 1). https://youtu.be/W-D71ZeMixQ?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr. Accessed 3rd January 2023.
  4. Neso Academy. Introduction to Classes and Objects (Part 2). https://youtu.be/Kk6dlF59yGg?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr. Accessed 3rd January 2023.
  5. Neso Academy. Creating a Class in Java. https://youtu.be/EplETikbJis?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr Accessed 3rd January 2023.
  6. Neso Academy. Instantiating Objects in Java. https://youtu.be/Z-Y-7jND_Dc?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr. Accessed 3rd January 2023.
  7. Neso Academy. Constructors in Java. https://youtu.be/HbQ2ASDc0Lw?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr. Accessed 3rd January 2023.
  8. Neso Academy. Creating a Class in Java – Practice. https://youtu.be/dDL4gpuQyzA?list=PLBlnK6fEyqRiwWLbSXKFtdGV8OVqr9dZr. Accessed 3rd January 2023.
  9. Wang Jackie. CSE114 Lab 20151008 Point Class and Objects. https://youtu.be/-Ol02U2speE. Accessed 2ndJanuary 2024

History