You are on page 1of 5

CIS/355 iLab 4 of 6

iLab 4 of 6: Inheritance and Simple GUI
iLAB OVERVIEW Scenario and Summary

In this lab you will create one project that uses inheritance and two simple Graphical User Interface (GUI) programs.

Deliverables Program files for each of the following three programs
1. 2. 3.

InheritanceTest DayGui OfficeAreaCalculator

At the beginning of ALL your programs, put a comment box that includes the program name, your name, and a brief description of the program. Example: /*********************************************************************** Program Name: ProgramName.java Programmer's Name: Student Name Program Description: Describe here what this program will do ***********************************************************************/ How to submit your assignment:
1. 2.

The programs MUST have the same names as the assignment title.

Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success. In addition to the program source code files and byte code files, put all your program source code files and screen shots of your program output files into a Word document.
3.

You must use a zipped folder to send your weekly assignment to the Dropbox. Do not send subfolders within your zipped folder. Place ALL of the .java and .class files for the week into the one zipped folder. The zip folder should be named: CIS355A_YourLastName_iLab_Week4, and this zip folder will contain all the weekly programming assignments.
4.

iLAB STEPS

STEP 1: InheritanceTest (20 points) Write a program called InheritanceTest.java to support an inheritance hierarchy for class PointSquare-Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class. The private variable of Point should be the x-y coordinates. The private data of Square should be the sideLength. The private data of Cube should be depth. Each class must provide applicable accessor, mutator, and toString() methods for manipulating private variables of each corresponding class. In addition, the Square class must provide the area() and perimeter() methods. The Cube must provide the area() and volume() methods. Write a program that instantiates objects of your classes, ask the user to enter the value for x, y, and sideLength, test all instance methods and outputs of each object’s perimeter, area, and volume when appropriate. Grading Rubric InheritanceTest Standard header included Program compiles Program executes Point class created Square class created Cube class created InheritanceTest class created Correct output is displayed Subtotal Points 1 1 1 3 3 3 4 4 20 Description Must contain program's name, student name, and description of the program Program does not have any error Program runs without any error Class contains accessor, mutator, and toString methods Class contains accessor, mutator, toString, perimeter, and area methods Class contains accessor, mutator, toString, area, and volume methods Test class asks user for input of x, y, and sideLength and tests all instance methods Test class produces correct output showing all values corresponding to each object

STEP 2: DayGui (10 points) Write a program called DayGui.java that creates a GUI having the following properties Object Property Setting

JFrame

Name Caption Layout Name Caption Mnemonic Name Caption Mnemonic

mainFrame Messages FlowLayout cmdGood Good G cmdBad Bad B

JButton

JButton

Add individual event handlers to your program so that when a user clicks the Good button, the message "Today is a good day!" appears in a dialog box, and when the Bad button is clicked, the message "I'm having a bad day today!" is displayed. The following tutorial shows you much of the code solution. Feel free to use the tutorial, but make changes so that you are not simply copying the tutorial code for your entire solution. To make this different from the tutorial, change the colors of the buttons and panel. Also, add this application to a tabbed pane along with the program you will complete in the next step, Step 3. The following tutorials will likely be useful as you work to complete this step:  JTabbedPane  Tutorial to Write Your First GUI Grading Rubric DayGui Standard header included Program compiles Program executes DayGui class created cmdGoodJButton created along with the event handler cmdBadJButton created along with the event handler Application contains required changes and displays the correct output Subtotal Points 1 1 1 1 1.5 Description Must contain program’s name, student name, and description of the program Program does not have any error Program runs without any error Class DayGui was created which contains the required properties The Good button shows on the application and when pressed the appropriate message displays on a separate window The Bad button shows on the application and when pressed the appropriate message displays on a separate window Application appears as one of the tabs in a tabbed application and buttons and panel are in different colors

1.5

3

10

STEP 3: OfficeAreaCalculator (10 points) Write a program called OfficeAreaCalculator.java that displays the following prompts using two label components  Enter the length of the office:  Enter the width of the office: Have your program accept the user input in two text fields. When a button is clicked, your program should calculate the area of the office and display the area in a text field with a label of Area. This display should be cleared whenever the input text fields receive the focus. A second button should be provided to terminate the application (Exit button). The following tutorial shows you much of the code solution. Feel free to use the tutorial, but make changes so that you are not simply copying the tutorial code for your entire solution. To make this different from the tutorial, change the colors of the panel. Also, add this application to the same tabbed pane (see the JTabbedPane tutorial) as the application you built in Step 2, the DayGui application.  Office Area Calculator Tutorial Grading Rubric OfficeAreaCalculator Standard header included Program compiles Program executes Created Length label and Length input textbox field Created Width label and Width input textbox field Created Area label and Area input textbox field Created Calculate button with the appropriate handler Created Exit button with the appropriate handler Application contains required changes and displays the correct output Points 1 1 1 1 Description Must contain program’s name, student name, and description of the program Program does not have any error Program runs without any error The Length label and input textbox show on the application and users can enter valid numeric value in the textbox The Width label and input textbox show on the application and users can enter valid numeric value in the textbox The Area label and input textbox show on the application and the area value displays in the textbox when the Calculate button is pressed The Calculate button calculates the area given the length and width of the office The Exit button exits the application and terminates the program Application appears as one of the tabs in a tabbed application and panel is in a different color

1

1

1 1 2

Subtotal

10

CLICK HERE TO GET THE SOLUTION !!!!!!!!!