Your task is to complete various exercises in NetBeans, using the Java language
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your task is to complete various exercises in NetBeans, using the Java language

Specifications

Your task is to complete various exercises in NetBeans, using the Java language.

Part 1 – Classes and objects

Create a new Java project called usernamePart1 in NetBeans. In my case, the project would be called pdarcyPart1. Select the option to create a main method.

Create a new class called ArtObject. In the Art Object class, write the code for:

• Instance variables that store the art object’s title, artist, year created, and description.

• A default constructor, and a second constructor that initialises all the instance variables.

• Accessor (getters) and mutator (setters) methods for all instance variables.

• A method called printDetails that prints the ArtObject details, e.g. “The ArtObject details are:” followed by all instance variables. The output must be formatted for readability.

In the main method, write the code to:

• Create 2 art objects, one using the default constructor, the other using the constructor that initialises all the instance variables for the art object.

• Demonstrate the use of one accessor method and one mutator method for one of the art objects you created.

• Print the art object’s details using the printDetails method for one of the art objects you created.

Part 2 – Inheritance, collections and polymorphism

Create a new Java project called usernamePart2 in NetBeans. Select the option to create a main method.

Create a new class called Sculpture. Create a second class called ArtObject. Copy the code from the ArtObject class you created in Part 1 into the new ArtObject class.

Modify the new Sculpture class so that it extends ArtObject class (ArtObject is the superclass, Sculpture is the subclass).

In the Sculpture class, write the code for:

• The instance variables that store the height, and weight.

• Accessor and mutator methods for the 2 instance variables.

• A default constructor, and a second constructor that initialises all the instance variables in the Sculpture and the ArtObject classes using the super keyword.

• The ArtObject class has a method called printDetails that prints the ArtObject details. Override the printDetails method in the Sculpture class and print all of the sculpture’s details. The printDetails method in the Sculpture class must use the super keyword to call the printDetails method in the ArtObject class.

• The Sculpture class must also demonstrate the use of overloaded methods.

In the main method, write the code to:

• Declare an ArrayList with a type parameter of Sculpture.

• Add at least 2 sculptures to the ArrayList.

• Use an Iterator (java.util.Iterator) to loop through the sculptures in the ArrayList and print out some of their details.

• Check if the ArrayList contains a particular sculpture.

• Get a sculpture from the ArrayList.

• Remove a sculpture from the ArrayList.

• Print the size of the ArrayList.

• Clear the ArrayList.

Please note that collections are covered in Topic 3 and 4. You may need to wait until we have covered these topics to implement your ArrayList.

Polymorphism

In the class that contains the main method, create a second method that takes an art object’s as a parameter and write the code to print out the art object’s artist using one of the ArtObject’s accessor methods. Then create an object of type Sculpture and an object of type ArtObject in the main method and use the method you have just created to demonstrate polymorphism.

Part 3 – Abstract classes

Create a new Java project called usernamePart3 in NetBeans. Select the option to create a main method.

Create a new class called Sculpture. Create a second new class called ArtObject. Rewrite your code from Part2 so that:

• The ArtObject class is abstract

• Sculpture extends ArtObject

• The ArtObject class contains at least one abstract method

All methods, constructors and instance variables that were in the Sculpture and ArtObject classes in part 2 must be included in part 3. You need to rewrite the Sculpture and ArtObject classes from part 2 so that ArtObject is abstract and there are multiple ways to create a sculpture.

Check your code works by creating a new sculpture in your main method.

Part 4 – Interfaces

Create a new Java project called usernamePart4 in NetBeans. Select the option to create a main method.

Create a new class called Sculpture. Create a new interface called ArtObject. Rewrite your code from Part 2 so that:

• ArtObject is an interface

• Sculpture implements ArtObject

• The ArtObject interface contains at least one abstract methods

All methods, constructors and instance variables that were in the Sculpture and ArtObject classes in part 2 must be included in part 4. You need to rewrite the Sculpture and ArtObject classes from part 2 so that ArtObject is an interface and there are multiple ways to create a sculpture. 

In the main method of your project, write the code to:

• Declare a Stack with a type parameter of Sculpture

• Add at least 3 sculptures to the Stack

• Demonstrate the use of:

o peek()

o pop()

o empty()

Part 5 – UML

Create a word document called usernamePart5. Draw 2 UML diagrams to show the inheritance relationship for the Art Object and Sculpture in part 3 and part 4. Make sure that each diagram has a heading and the header of the word document contains your name and student ID.

Hint
ComputerJava project is the process of developing a software environment that provides a collection of tools that are required to develop Java. Java is one of the known and essential language that is utilized to develop web applications and platforms....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.