Description
Assignment Description
1. First, create an Intellij Java project and name it “pa5_your-id”.
2. Start by creating a normal (POJO, JavaBean) class to represent, i. e. model, a rectangle based on length
and width. Include private data members, constructors, getters (accessors) and setters (mutators). Move
beyond a normal class by including a public method to return the area of the rectangle. Length and width
must be greater than zero. Only constructors and setters may be passed parameters. Setters may only be
passed one parameter.
3. Inherit the rectangle class into a class that starts as a normal (POJO, JavaBean) class. This new
represents, i. e. models, a box based on length, width and depth. Without unnecessarily replicating any
features of the super class, include any necessary private data members, constructors getters (accessors)
and setters (mutators). Include three constructors, one default that receives nothing, one that that
receives length, width and depth values, and one that receives a rectangle class object reference plus a
depth value. Include a method to return the area of the box and a method to return the volume of the
box. Length, width and depth must be greater than zero. Only constructors and setters may be passed
parameters. Setters may only be passed one parameter.
4. In method main of class Main, write the Java code to demonstrate the use of the constructors and
methods of both classes, including using an array of the superclass that contains objects of both classes.
In your demonstration code, checking the type and casting an object to the subclass when appropriate is
required.
(continued on the next page)
CMPS 260 Spring 2019 Programming Assignment #5 (2019.03.03) 2
Additional Requirements
(a)If there is user input, a reference variable and instance object of class java.util.Scanner must be used to
read the input from the user. Prompts for any user input must be clear and relevant.
(b)Output to the user must include appropriate labels.
(c)Identifiers must be descriptive, i. e. must self document. The only exception granted is in the case of a
“for variable”, that is a variable created as a simple counter as in the control variable in a “for” loop
statement.
(d)Indention of all code blocks (compound statements, anything in braces), including single statements
following selection or while statements, is required.
(e)The main “.java” file [the one with the method public static void main(String[] args)] of your Intellij
projects must contain this minimal documentation as the first lines of the file (i. e. above the package
statement):
// Your Name
// Your ID
// CMPS 260
// Programming Assignment : #
// Due Date :
// Program Description: (a brief description of actions of your code)
// Certificate of Authenticity:
(Choose one of the two following forms:)
// I certify that the code of this project, other than that that was generated by Intellij, is entirely
// my own work.
{or}
// I certify that the code of this project, other than that that was generated by Intellij, is entirely
// my own work, but I received some assistance from {name}. Follow this with a description of
// the type of assistance. (For example, if you consulted a book, and your solution incorporates
// ideas found in the book, give appropriate credit; that is, include a bibliographical reference.)
// Note: You do not have to list the text, the author of the course text or the instructors examples.
Submitting
In Intellij, select File, Save All, then select File, Export to Zip File and click OK to save the Zip archive
file. Finally, upload the zip archive file to Moodle.
Helpful Hint: Keep a backup copy of your project folder on a Google Drive, a Drop Box Account, a USB
memory device, etc., or even on Moodle! Finally, once you turn in your final version, create a copy
before the due date and do not change this copy in any way. This final copy can be consulted if there is
an upload disaster, but only if the “.java” files have not been changed in any way after the due date.