Subject Code & Title : CSE1IOX Intermediate Object – Oriented Programming
Assignment Number: Assessment 1
Assignment Type: Individual Assessment
Background:
Green Guard is a garden maintenance company that is growing quickly. The company is struggling to keep track of all their equipment and have engaged you to develop a program to assist them with identifying when their equipment needs to be replaced.
CSE1IOX Intermediate Object Oriented Programming Assessment 1 – Australia.
Inheritance and Polymorphism
Background:
Green Guard is a garden maintenance company that is growing quickly. The company is struggling to keep track of all their equipment and have engaged you to develop a program to assist them with identifying when their equipment needs to be replaced.
‘Green Guard’ has three categories of equipment:
• Standard equipment (i.e. Rakes, Brooms and Shovels)
• Fuel powered equipment (i.e. Lawn Mowers, Chainsaws)
• Battery powered equipment (i.e. Edge Trimmers, Brush Cutters)
The program will need to be able to manage:
• The display of common information about all equipment
• The display of information relevant to specific equipment categories
• When a piece of equipment needs to be replaced
It is recommended that you read through all the tasks before commencing work on your assessment.
This assessment consists of the creation of one abstract class and three inherited classes. You may wish to consider implementing and testing the abstract class and one of its inherited classes before implementing all classes. The Battery Powered Equipment class is most straight forward to implement.
Requirements:
In terms of when equipment needs to be replaced, that depends on the type of equipment:
• Battery Powered Equipment needs to be replaced when the equipment warranty runs out using the following formula:
Replacement Year = Length of Warranty + Purchase Year
i.e. for a battery powered item with a warranty of 2 years purchased in 2022
Replacement Year = 2 + 2022
Replacement Year = 2024
• Fuel Powered Equipment needs to be replaced after being used for more than 500 days.The number of days that a piece of equipment is used in a year is approximated to determine when it should be replaced using the following formula:
Replacement Year = Maximum Days / Days Usage Per Year + Purchase Year
i.e. for a fuel powered item that is used approximately 100 days in a year purchased in 2022
Replacement Year = 500 / 100 + 2022
Replacement Year = 2027
CSE1IOX Intermediate Object Oriented Programming Assessment 1 – Australia.
• Standard equipment needs to be replaced a maximum of 7 years after it was purchased,but this is also dependent on the durability of the equipment. A durability factor is used to assist in determining the replacement date. The durability factor is a number between 0 and 1. The overall calculation of the replacement year is made using the following formula.
Replacement Year = Maximum Lifespan * Durability Factor + Purchase Year
i.e. for a standard item with a durability of 0.6 purchased in 2022
Replacement Year = 5 * 0.6 + 2022
Replacement Year = 2025
Replacement years should always be rounded up
Tasks:
Task 0 – Creation of Net Beans Project
As a starting point create a new Net Beans project and give it the name ‘Replacement Test’. Your main class for the project should (by default) have the same name. The aim of this class is to enable testing to determine if all aspects of the program are working as expected. You can use it to run testing as you develop your project and also once it is complete.
Task 1 – Creation of Abstract Equipment Class
You have determined that the program would be best managed using an abstract class as a starting point.
The Equipment abstract class will feature standard properties and methods that are common between all equipment categories
Abstract Class – Equipment
Task 2 – Creation of Battery Powered Equipment Class
You are to create a class named ‘Battery Powered Equipment’. This class is designed to keep track of the replacement of battery powered equipment such as Edge Trimmers and Brush Cutters.
You will need to create the class as outlined below:
• The ‘Battery Powered Equipment’ class should inherit from the ‘Equipment’ class (take advantage of super)
• The class should have a property to store the warranty (measured in years) of individual items and should also have associated functions to get and set the usage.
• At class initialisation you should be able to set the make, model, purchase date and warranty of the item
• The replacement Year function should be overridden to return the replacement year (based on calculations outlined in the requirements section)
Class – Battery Powered Equipment
Task 3 – Creation of Fuel Powered Equipment Class
You are to create a class named ‘Fuel Powered Equipment’. This class is designed to keep track of the replacement of fuel powered equipment such as lawn mowers and chainsaws.
You will need to create the class as outlined below:
• The ‘Fuel Powered Equipment’ class should inherit from the ‘Equipment’ class (take advantage of super)
• The class should have a constant value that sets the maximum number of days an item can be used for.
• The class should have a property to store the usage (measured in days per year that an item is used) of individual items and should also have associated functions to get and set the usage.
• At class initialisation you should be able to set the make, model, purchase date and usage of the item
• The replacement Year function should be overridden to return the replacement year (based on calculations outlined in the requirements section)
Class – Fuel Powered Equipment
Task 4– Creation of Standard Equipment Class
You are to create a class named ‘Standard Equipment’. This class is designed to keep track of the replacement of standard (non-powered) equipment such as rakes, brooms and shovels.
You will need to create the class as outlined below:
• The ‘Standard Equipment’ class should inherit from the ‘Equipment’ class (take advantage of super)
• The class should have a constant value that sets the maximum time an item can be retained
• The class should have a property to store the durability of individual items and should also have associated functions to get and set the durability
• At class initialisation you should be able to set the make, model, purchase date and durability of the item
• The replacement Year function should be overridden to return the replacement year (based on calculations outlined in the requirements section)
Class – Standard Equipment
Task 5 – Testing Using Replacement Testing Class
This class should have already been created as part of Task 0.
As part of the ‘main’ method of this class you should:
• Create two instances of each of the three types of Equipment classes using dummy data
• The output should be according to what has been defined in the ‘show Details’ method in each class. Your output should be starting to look like that as outlined under Figure 1 – Expected Output (the exceptions are covered as part of the next Task)
Task 6 – Exceptions:
You will need to run some checks on the validity of data been entered. It is expected that the program will throw an exception in the following circumstances:
• If the warranty of a Battery Equipment item is 0 or less
• If the durability of a Standard Equipment item is 0 or less OR greater than 1
CSE1IOX Intermediate Object Oriented Programming Assessment 1 – Australia.
You must have a catch block that catches these exceptions and displays an appropriate error message. (You can use the get Message method of the Throw able class to achieve this)
You only need to alert the user to there being an error with the entered data. You do not need to manage this in any other way at this point.
Your output should be similar to that outlined under Figure 1- Expected Output below
Task 7 – Comments
Ensure you include appropriate comments in your code including:
• Purpose of classes
• Purpose of methods
• Explanatory notes for any potentially confusing items
CSE1IOX Intermediate Object Oriented Programming Assessment 1 – Australia.