Question: There are two separate sections this week. The first section is a very bare bones abstract design and code to demonstrate inheritance, polymorphism, and exception
There are two separate sections this week. The first section is a very bare bones abstract design and code to demonstrate inheritance, polymorphism, and exception handling. The second is a very practical example of GUI components to make a workable calculator.
Students, please note: You are being evaluated on your ability to write Java and understand Java. As a demonstration of your understanding, please use many, many (every line is a good idea) comments throughout your code assignments.
Five files: Demo.java , ExceptionA.java , ExceptionB.java , ExceptionC.java , CalculatorForm.java .
At the beginning of all of your programs, put your name and a brief description of the program.
Example:
/*Sally Smith
This program will calculate area of a
triangle, etc...*/
Add many comments to the body of your code so as to demonstrate a thorough understanding of your program
SECTION 1: Catching Exceptions With Superclasses
Use inheritance to create an exception superclass called ExceptionA and exception subclasses ExceptionB and ExceptionC, where ExceptionB inherits from ExceptionA and ExceptionC inherits from ExceptionB. Write a program to demonstrate how one catch block can catch all three types of exceptions. That is the catch block for type ExceptionA that catches exceptions of types ExceptionB and ExceptionC. The idea here is to have you write and understand exception handling and get a sense of how you might use it in your final project.
SECTION 2: Calculator
Write a Java program named CalculatorForm.java that will display a form that does simple numeric calculations. The form should look like this:
The form should successfully do simple integer arithmetic on integer numbers that are input. That is, the program should work correctly. When the user enters integer input and then presses the calculate button, the program should display an integer answer in the answer text field. (It's ok to do integer arithmetic and truncate decimal values.) When the user clicks the exit button or the window-closing button, the program should end.
For right now, assume that the user will only enter integer numbers.
If the user does not enter two numbers, or tries to do "division by zero," the program should indicate that something is invalid.
A Simple Calculator Form O X First number: add O subtract Operation: O multiply O divide Second number: Answer: calculate exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
