Approaches to Improve the Program

Date:  2021-03-06 06:46:33
3 pages  (793 words)
Back to categories
This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The program employs the use Main classes and subclasses. The subclasses extends the Main class to uphold the Main properties of the program. The main class which is referred as the superclass also have the collection of the animals required.

The instance of operator

This operator is used to call the main the method based explicitly on the class of some object, instead of using an implicitly using an overridden method and polymorphism. However, this operator should be used as a last resort. One should use the format below which is simpler and more efficient.

animal = new Fish();


animal = new Spider();


J-Option Pane

The use of println to output text is efficient, but it only works on the IDE Log, making it a bit difficult to handle. The use of J-Option pane can solve this problem since it creates interactive pop-ups and makes the program more user-friendly.

JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);


The Approach the Team has Taken to Improve the Program

The first approach we took was to examine the whole functionality and how the program was supposed to run. The program contains different animal classes but being animals; they share some characteristics, and we had to create a general class of animals. The individual animal class is as below:

public class Bird extends Animal


public Bird()


System.out.println(" You added a bird.");



The above class shows the unique characteristics and the name of the specified class of animals. This approach ensures theres no confusion between animal classes and there specific characteristics during the runtime of the program. Also, the individual animal classes refer to a central class displaying what the animals do.

public class Animal


public Animal()


if (this instanceof Fish)

System.out.println("Fish have scales, lay eggs, and can swim. ");

else if (this instanceof Bird)

System.out.println("Birds can fly, lay eggs, and have feathers.");

else if (this instanceof Snake)

System.out.println("Snakes have scales, lay eggs, and can be venimous.");



The above class makes this program efficient and improved since it's like a central hub for displaying what animal does when the input on the IDE Log console.

The other approach we took to improve the program was by the use of the arrays. An array stores a list of data of the same type for quick access and retrieval of the stored elements. In our case we use a string array to store the types of animals, were going to deal with in our program which makes our program specific and precise to the point of what we want to accomplish. The array used is as below,

public static void main(String [] args)


ArrayList<Animal> animalArr = new ArrayList<>();//animal array

Scanner scan = new Scanner(;


case 'f' : animalArr.add(new Fish()); break;

case 'b' : animalArr.add(new Bird()); break;

case 's' : animalArr.add(new Snake()); break;

default: System.out.println("That is not a valid animal type.");



The program will reject any animal that is not specified by the array by throwing the default error message in our switch-case argument above. This approach ensures that we stick within the parameters required by our program. If you try an animal which is out of the ones specified is as below.

System.out.println ("Option not available, please choose again.");

The other approach we took was to make the program accept input and become interactive. This will test the programs the running ability, whether it has runtime errors or compile time errors resulting into erroneous output in the end.

System.out.println ("Please enter your choice: ");

We took the approach to use println that displays on the IDE Log console; this requires less resources during runtime hence making the program execute faster, hence, we used as an optimization method for the program.

Why some of the Changes are Relevant?

The changes are relevant since the code should optimize the program we write so that compile time and run time are reduced hence faster execution during run-time. Some of the changes also aid with better user friendliness and make it easier for the user to understand what the program is supposed to do.

Challenges Encountered by the Team

As a team, we encountered some challenges. Setting up classes for the project and linking them up with the superclass presented a challenge, but finally, we did manage. Also deciding on the suitable idea array indexing was challenging. The team also faced some changes in coordination, but finally, we managed. Time was also a factor the presented a challenge.

The suggested improvements should include that we are given more time to research extensively so that we can develop a cutting edge program thats well coded and tested to the limits.



Request Removal

If you are the original author of this essay and no longer wish to have it published on the ProEssays website, please click below to request its removal: