Starting from:

$30

BBM104-Quiz 2 Classes, Constructors, Inheritance Solved

Write an object oriented program that allows users to manage the members of Fitness Center. The sport center has more than one person and each person may register either as a personal trainer or as a member.

The program should store all of the information (i.e. id (must start at 1), name, surname, height, weight, etc.) as shown in Figure 1.

 

Figure 1: UML class diagram of Sport Center

Create a Person class with:

•    Several attributes: id, name, surname.

•    One constructor method which receives all attributes as parameters.

 

1

Create a PersonalTrainer class with:

•    Several attributes: Member[] members, sportType.

•    One constructor method which receives all attributes as parameters (id, name, surname, sportType).

•    addMember(Member m): adds members to the specified PT.

•    returnCountofMembers(): returns the count of specified PT’s members.

•    returnMember(int memberID): returns Member instance.

•    ReturnFattestMember(): Returns the fattest member PT has.

Create a Member class with:

•    Several attributes: heigth, weight. These attributes must be private.

•    One constructor method which receives all parameters (id, name, surname, weight, height).

•    Get / Set methods

•    bmi() method: calculates Body Mass Index of the member. The formula for BMI index is shown in Figure 2. W represents weight, and H represents height of members.

 

Figure 2: The formula of BMI index

•    weightStatus() method: returns the weight status of the member as String by calling BMI method.

 

Create a SportCenter class with:

•    Several attributes: name of the sport center, PersonalTrainer[] PTs.

•    One constructor which receives name as parameter

•    addPT(PersonalTrainer pt) method: adds personal trainer to the sport center

•    searchPT(String name, String surname) method: returns an instance of type ”PersonalTrainer”.

More products