Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CSIS 505 CSIS 505 Homework 1 Instructions CSIS 505 Exception Handling Assignment Instructions Overview In this assignment, you will complete two exercises that will allow you to practice your skill...

1 answer below »

CSIS 505
        CSIS 505 Homework 1 Instructions
        CSIS 505
Exception Handling Assignment Instructions
Overview
In this assignment, you will complete two exercises that will allow you to practice your skill with the topics of interfaces and exceptions that you learned about in the Learn section.
Instructions
1. Refer to the Assignments Grading Ru
ic before you begin this assignment.
2. Complete the detailed instructions for each exercise included in the sections below. For each exercise, begin with a new Java project.
3. As you write your code, provide all pertinent documentation in the form of JavaDoc comments for all classes and methods.
a. All class-level comments must include a description of the class along with your name and links to any outside resources you used (other than the textbook) while writing your code.
. Each method must also have a comment that indicates the purpose of the method and, if applicable, the purpose of all parameters and return value.
c. Additional in-line comments must be used to explain complex algorithms or unique solutions to the problem.
4. After you have completed the exercises for this assignment, submit a Word document containing screenshots of the assignment executing on your machine.
Exercise 1
Governments and companies worldwide are becoming increasingly concerned with ca
on footprints (annual releases of ca
on dioxide into the atmosphere) from buildings burning various types of fuel for heat, vehicles burning fuels for power, and the like.
1. Create 3 small classes unrelated by inheritance: Building, Car, and Bicycle
2. Give each class the unique attributes and behaviors as specified in the class diagram in Figure 1 below. Create a single constructor for each class to allow consumers of the class to provide initial values for each attribute.
3. Write an interface Ca
onFootprint with a getCa
onFootprint method.
4. Have each of your classes implement that interface so that its getCa
onFootprint method calculates the appropriate ca
on footprint for that class, as specified below:
a. Building footprint = ([monthly gas bill / 10.68] * 119.58 * 12) + ([monthly electric bill / 0.1188] * 1232 * 12)
. Car footprint = miles driven per year / miles per gallon * 19.82
c. Bicycle footprint = miles traveled per month * 0.9
5. Write an application that does the following:
a. Creates objects of each of the 3 classes
. Places references to those objects in an a
ay of Ca
onFootprint
c. Iterates through the a
ay, polymorphically invoking each object’s getCa
onFootprint method
d. For each object, print identifying information, such as miles traveled or monthly bill amount, along with the object’s ca
on footprint.
Exercise 2
Extend Exercise 1 by creating and demonstrating the use of an InvalidFootprintException class.
1. Create the 4 constructors as discussed in this module/week’s presentations.
2. Extend the appropriate superclass.
3. Throw the InvalidFootprintException in the constructor of the Building, Car, and Bicycle classes if any of the provided parameter values are negative.
4. Add code in your main method that handles the InvalidFootprintException, and write code that demonstrates that your handler works (i.e., write code that purposefully causes the InvalidFootprintException to be thrown, but then ensure that it does not crash your program). Instead of crashing, your main method must print a message to the e
or stream that an invalid footprint was detected.
Figure 1. Exercise 1 Class Diagram
Page 1 of 3
Page 4 of 4
        Page 1 of 2
Answered Same Day Jan 31, 2022

Solution

Kshitij answered on Jan 31 2022
111 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here