1. Homepage
  2. Exam
  3. [2022] UOW - CSIT121 Object Oriented Design and Programming - Final Exam - Q3 Rectangle, Cuboid and Pyramid

[2022] UOW - CSIT121 Object Oriented Design and Programming - Final Exam - Q3 Rectangle, Cuboid and Pyramid

This question has been solved
Engage in a Conversation

Question 3 CourseNana.COM

  CourseNana.COM

Write a Java program to allow user to create instances of Rectangle, Cuboid and Pyramid; and search the instances by different criteria. The details of the classes are given as follows: CourseNana.COM

  CourseNana.COM

class CourseNana.COM

Rectangle CourseNana.COM

Instance variables CourseNana.COM

Length and width of a rectangle. CourseNana.COM

You may decide the type of each instance variable. CourseNana.COM

You may include additional variables as you deem fit. CourseNana.COM

Constructor CourseNana.COM

A non default constructor that receives parameters and initialises the instance variables. CourseNana.COM

Get and set methods CourseNana.COM

Include get and set methods for all instance variables. CourseNana.COM

getArea CourseNana.COM

Instance method to calculate and return the rectangle's area, which is length x width. CourseNana.COM

toString CourseNana.COM

Return a descriptive String of the instance. CourseNana.COM

  CourseNana.COM

class CourseNana.COM

Cuboid (subclass of Rectangle) CourseNana.COM

Instance variables CourseNana.COM

Height of a cuboid. CourseNana.COM

You may decide the type of each instance variable. CourseNana.COM

You may include additional variables as you deem fit. CourseNana.COM

Constructor CourseNana.COM

A non default constructor that receives parameters and initialises the instance variables, including the instance variables of the base class. CourseNana.COM

Get and set methods CourseNana.COM

Include get and set methods for all instance variables. CourseNana.COM

getArea CourseNana.COM

Instance method to calculate and return the surface area (6 sides) of a cuboid. CourseNana.COM

getVolume CourseNana.COM

Instance method to calculate and return the volume of a cuboid, which is base area x height. CourseNana.COM

toString CourseNana.COM

Return a descriptive String of the instance. CourseNana.COM

  CourseNana.COM

class CourseNana.COM

Pyramid (subclass of Rectangle) CourseNana.COM

Instance variables CourseNana.COM

Height of a pyramid. CourseNana.COM

You may decide the type of each instance variable. CourseNana.COM

You may include additional variables as you deem fit. CourseNana.COM

Constructor CourseNana.COM

A non default constructor that receives parameters and initialises the instance variables, including the instance variables of the base class. CourseNana.COM

Get and set methods CourseNana.COM

Include get and set methods for all instance variables. CourseNana.COM

getVolume CourseNana.COM

Instance method to calculate and return the volume of a pyramid, which is (base area x height) / 3. CourseNana.COM

toString CourseNana.COM

Return a descriptive String of the instance. CourseNana.COM

  CourseNana.COM

Note: The Pyramid class does not override the getArea method. CourseNana.COM

  CourseNana.COM

The program must read a text file containing the instance data, create an appropriate instance (Rectangle, Cuboid or Pyramid) for each data, and store it in an ArrayList for subsequent use. A sample of the text file is shown below. CourseNana.COM

C,10.5,20.5,30 CourseNana.COM

P,5,10,15.3 CourseNana.COM

R,2,5.5 CourseNana.COM

P,2,5,10 CourseNana.COM

C,5,A,20 CourseNana.COM

P,0,10,-1 CourseNana.COM

C,8,10,15 CourseNana.COM

  CourseNana.COM

The program will skip erroneous lines in the file. After the instances are created and stored in an ArrayList, the program will allow user to perform the following operations repeatedly: CourseNana.COM

1 Search by length CourseNana.COM

2 Search by height CourseNana.COM

3 Quit CourseNana.COM

  CourseNana.COM

Option 1 CourseNana.COM

The program will prompt the user to enter a number (length) and display all instances with length >= the length entered by the user. The program will display an appropriate message if there is no matching instance. The program must handle incorrect data input: non-numeric input and invalid length (0 or negative). CourseNana.COM

  CourseNana.COM

Option 2 CourseNana.COM

The program will prompt the user to enter a number (height) and display all instances with height >= the height entered by the user. The program will display an appropriate message if there is no matching instance. The program must handle incorrect data input: non-numeric input and invalid height (0 or negative). CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
CSIT121代写,Object Oriented Design and Programming代写,University of Wollongong代写,UOW代写,CSIT121代编,Object Oriented Design and Programming代编,University of Wollongong代编,UOW代编,CSIT121代考,Object Oriented Design and Programming代考,University of Wollongong代考,UOW代考,CSIT121help,Object Oriented Design and Programminghelp,University of Wollongonghelp,UOWhelp,CSIT121作业代写,Object Oriented Design and Programming作业代写,University of Wollongong作业代写,UOW作业代写,CSIT121编程代写,Object Oriented Design and Programming编程代写,University of Wollongong编程代写,UOW编程代写,CSIT121programming help,Object Oriented Design and Programmingprogramming help,University of Wollongongprogramming help,UOWprogramming help,CSIT121assignment help,Object Oriented Design and Programmingassignment help,University of Wollongongassignment help,UOWassignment help,CSIT121solution,Object Oriented Design and Programmingsolution,University of Wollongongsolution,UOWsolution,