Page 1 of 8
DEPARTMENT OF INFORMATION AND COMMUNICATIONS TECHNOLOGY (TSING YI)
HD in Data Science and Analytic
HD in Telecommunication and Networking
ITP4905 Object Oriented Programming
Assignment
Assignment Due Date and Time: 11 April 2024 (Thursday) 23:55 (through Moodle)
Fitness Centre System
A fitness centre in the local area has decided to modernise its management system for classes and
equipment. To simplify the process, the centre has opted to implement a new system using Java
with an object-oriented approach. The system will efficiently manage various types of fitness
classes and gym equipment, allowing the centre’s manager to easily manage on the system as
needed.
You are required to take the Java Object Oriented Approach to develop a prototype for a fitness
centre. This prototype provides a comprehensive system for managing a fitness centre. It will allow
operations such as adding, removing, and displaying various fitness classes and equipment.
Please note that the following classes are necessary for the proper functioning of this prototype:
1. FitnessItem.java
2. FitnessClass.java
3. Equipment.java
4. Manageable.java
5. MaxNumberException.java
6. FitnessCenterSystem.java
When developing your system prototype, you are required to handle all possible exceptions that
could occur. To do this, you should use try-catch blocks and provide error messages that are easy
for the user to understand.
Page 2 of 8
The class descriptions and sample program will be shown below.
Class Descriptions
1. FitnessItem
FitnessItem is an abstract class that serves as a base for different types of fitness items in the
system. It implements Serializable. This class has the following structure:
Attributes
itemName A string representing the name of the fitness item.
usageTime A decimal number representing the average usage time in hours per day.
Constructor Initializes a fitness item with its name and usage time.
Abstract
Method
printDetails An abstract method to be implemented by subclasses in order to print the
details of the fitness item.
Other Methods
Setter/Getter Standard getters and setters for the attributes.
toString An overridden method that returns a string representation of the fitness item.
2. FitnessClass
The FitnessClass class is a subclass of FitnessItem. It represents a fitness class at the fitness center.
Its structure is as follows:
Attributes
maxParticipants An integer variable hold the maximum number of participants in the fitness
class
Constructor Initializes the FitnessItem item with its name, usage time and max number
of Participants.
Methods
getMaxParticipants Getter method for the maximum number of participants
setMaxParticipants Setter method for the maximum number of participants
printDetails Overridden method from FitnessItem that prints out the details of the
FitnessClass in a formatted manner.
Other Methods
toString An overridden method that returns a string representation of the
FitnessClass
3. Equipment Class
Page 3 of 8
The Equipment class is a subclass of FitnessItem. It represents a type of gym equipment found in a
fitness center. Its structure is as follows:
Attributes
equipmentType A string representing the type of equipment (e.g., "Cardio", "Strength" and
etc).
spaceRequired A double representing the amount of space required for the equipment in
square meters.
Constructor Initializes the equipment item with its name, usage time, equipment type,
and space required.
Methods
getEquipmentType Getter for the equipment type.
setEquipmentType Setter for the equipment type.
getSpaceRequired Getter for the space required.
setSpaceRequired Setter for the space required.
printDetails Overridden method from FitnessItem that prints out the details of the
equipment in a formatted manner.
toString An overridden method that returns a string representation of the Equipment
4. Manageable Interface
The Manageable interface comprises a set of methods that allow the system to manage fitness
items.
Methods
addNewItem Adds a new FitnessItem to the system.
It accepts a FitnessItem object as an argument
Throws MaxNumberException if the max number limited is exceeded
removeItem It removes a fitness item from the management system
It accepts the name of the item as a string argument
findItem Finds and returns a FitnessItem by name.
It Accepts the name of the item as a string argument
It Returns the found FitnessItem object, or null if not found
5. MaxNumberException
The MaxNumberException is a subclass of Exception. It is a custom exception that is thrown when
a maximum number limit is exceeded.
Methods
Constructor It accepts String errorMessage as the specified detail message.
6. FitnessCenterSystem
The FitnessCenterSystem class, which implements the Manageable interface, manages the
operations of a fitness center. It handles user interactions and manages fitness items such as classes
and equipment. The major components include:
Page 4 of 8
Attributes
equipmentItems An array of FitnessItem objects to store different equipment.
fitnessClasses An array of FitnessItem objects to store different fitness classes.
MAX_EQUIPMENT A constant integer representing the maximum number of equipment
items (set to 5).
MAX_CLASSES A constant integer representing the maximum number of fitness classes
(set to 5).
equipmentCount An integer counter for the current number of equipment items.
classCount An integer counter for the current number of fitness classes.
scanner A Scanner object for reading user input.
Constructors
Default constructor initializes the fitnessItems list
Constructor with a filename parameter to load fitness data from a file.
(Only required in advanced stage )
Methods
startSystem Starts the fitness center system and displays the menu to the user.
addFitnessItem Adds a new fitness item (class or equipment) based on user input.
findFitnessItem finds a fitness item based on user input.
displayFitnessItems, Display methods for FitnessItems
displayEquipmentItems Display methods for EquipmentItems
displayFitnessClass Display methods for FitnessClass
loadFitnessData Loads fitness items data from a given file.
findItem an override method from the Manageable interface
to find an item.
addNewItem an override method from the Manageable interface
to add an item.
removeItem an override method from the Manageable interface
but no implementation is required
Prototype of the System
The system can store up to 5 equipment items and 5 fitness classes. The program should present an
option menu for the user to select their desired action after execution.
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
1. Adding New Fitness Class
Choose to add a fitness class, enter name "Yoga Class", usage time 2 hours, and max participants
20.
Page 5 of 8
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 1
Add Fitness Item:
1. Fitness Class
2. Equipment
Choose type: 1
Enter item name: Yoga Class
Enter usage time (in hours): 2
Enter max Participants: 20
Item added: Yoga Class, 2.0 hours/day, max participants=20
Show the menu again...
2. Test Adding New Equipment
Choose to add equipment, enter name "Treadmill", usage time 1 hour, equipment type "Cardio",
and space required 10 sq.m.
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 1
Add Fitness Item:
1. Fitness Class
2. Equipment
Choose type: 2
Enter item name: Treadmill
Enter usage time (in hours): 1
Enter equipment type: Cardio
Enter space Required: 10
Item added: Treadmill, 1.0 hours/day , equipmentType=Cardio, spaceRequired=10.0
Show the menu again...
3. Find a Fitness Item
Choose to find a fitness item, enter the name "yoga".
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 2
Enter the name of the item to find: Yoga
Item found:
FitnessClass Yoga 2.0 Max Participants: 30
Page 6 of 8
Show the menu again...
4. Find an Equipment
Choose to find a fitness item, enter the name "Treadmill".
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 2
Enter the name of the item to find: Treadmill
Item found:
Equipment Treadmill 4.0 Type: Cardio, Space Required: 10.0 sq.m
Show the menu again...
5. Find a non-existent item
Choose to find a fitness item, and enter the name "hello".
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 2
Enter the name of the item to find: Hello
Hello is not available.
Show the menu again...
6. Test Display All Fitness Items
Precondition: Assume FIVE fitness class and FIVE equipment items are added.
Input: Choose to display all fitness items.
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 3
Fitness Center Items:
Type Description Hour Additional Info
Equipment Treadmill 4.0 Type: Cardio, Space Required: 10.0 sq.m
Equipment Dumbbells 5.0 Type: Strength, Space Required: 2.0 sq.m
Equipment Rowing Machine 3.0 Type: Cardio, Space Required: 8.0 sq.m
Equipment Exercise Bike 3.5 Type: Cardio, Space Required: 6.0 sq.m
Equipment Kettlebells 4.0 Type: Strength, Space Required: 3.0 sq.m
FitnessClass Yoga 2.0 Max Participants: 30
Page 7 of 8
FitnessClass Spinning 1.5 Max Participants: 25
FitnessClass Aerobics 2.0 Max Participants: 20
FitnessClass Zumba 1.5 Max Participants: 25
FitnessClass Pilates 2.0 Max Participants: 15
Show the menu again...
7. Test Maximum Capacity for Fitness Classes
Input: Repeatedly add Fitness Classes items until the count reaches 5(the maximum).
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 1
Add Fitness Item:
1. Fitness Class
2. Equipment
Choose type: 1
Enter item name: new class
Enter usage time (in hours): 2
Enter max Participants: 20
Max number of Fitness Classes have been created
Show the menu again...
8. Test Maximum Capacity for Equipment
Welcome to the Fitness Center Management System
1. Add a new fitness item
2. Find a fitness item
3. Display all items
4. Display all Equipment items
5. Display all fitness class
6. Exit
Choose an option: 1
Add Fitness Item:
1. Fitness Class
2. Equipment
Choose type: 2
Enter item name: new equipment
Enter usage time (in hours): 2
Enter equipment type: Cardio
Enter space Required: 2
Max number of Equipment have been created
Show the menu again...
9. Test Invalid Input
Input: Choose to add any new item but enter non-numeric values for usage time or max
participants.
Expected Output: An error message indicating invalid input and prompting for correct data.
Page 8 of 8
Advanced Stage (Optional)
As part of this bonus stage, you are optionally defining the loadFitnessData method. This method is
designed to load fitness item data from a specific file. This method allows users to be accurately
and efficiently loaded into your application.
Instructions to Students
1. This is an End of Module Assessment, and the weighting of this assignment is 20% of the Module
Mark.
2. This assignment should be done by each individual student. Plagiarism will be treated seriously.
All assignments that have been found involved wholly or partly in plagiarism (no matter these
assignments are from the original authors or from the plagiarists) will score Zero mark.
3. You must use Java JDK8 or above to develop the programs.
4. Your programs must follow the coding standard stated in Java coding standard published by
Oracle and Sun Microsystems. Marks may be deducted if the coding standard is not followed.
5. You are required to hand in
• A 1 to 2 pages word document briefly explains how your program shows the concept of
Object Oriented Programming (Abstraction, Encapsulation, Inheritance and Polymorphism).
• Source code of all classes which should be well-commented.
• The evidence of testing. Prepare a word document with a number of test cases showing
different inputs for different situations that your program may encounter and how your
program responses to show the capability of your program. For each test case, states the
objective of the test case, input data and expected result. You should also include screen
dumps for each test run as evidence.
6. Submit all your works (in a zip file under the name of your student ID – e.g. 23xxxxxxx.zip ) to
the Moodle website (http://moodle.vtc.edu.hk) by 23:55, 11 April 2024 (Thurday). Late
submission may score ZERO mark.
7. Mark Distribution
l Documentation and Evidence of Testing (10%).
l Exception Handling (10%)
l Basic Stage (80%):
n FitnessItem.java, FitnessClass.java Equipment.java,FitnessCenterSystem.java
Manageable.java, MaxNumberException.java. These classes are to be
implemented exactly as the listed requirements in this document.
n The system prototype contains the main method. You may add methods other
than main in your main class; and/or add other classes of your own to make
your system run.
l Optional Bonus Stage (max 10% bonus):
请加QQ:99515681 邮箱:99515681@qq.com WX:codinghelp