Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Programming Assignment

1. Getting Started

This assignment involves a health club management application. The following files have been posted to Blackboard and should be downloaded to the same folder on your computer:

(1) MembershipType.java: Abstract superclass for representing the various membership types that are available in the health club. Includes a concrete constructor that sets the values of the cost-related instance variables and the unique membership ID. Has one abstract instance method: toString().

(2) BasicMembershipType.java: Concrete subclass of MembershipType. Members with this membership type pay a yearly fee plus a usage fee for every visit. Student members get a discount on both types of fee, with the amount of the discount defined as a static constant in the superclass. This class doesn't have any instance variables beyond those defined in its superclass.

(3) FullMembershipType.java: Concrete subclass of MembershipType. Members with this membership type pay a higher yearly fee but are not charged for visits. Student members get the same discount as described above for basic memberships. This class doesn't have any instance variables beyond those defined in its superclass.

(4) FamilyMembershipType.java: Concrete subclass of MembershipType. Members with this membership type pay the highest yearly fee, which covers a primary member and a spouse. There are no charges for visits. An additional membership fee is charged for each additional member (child) that is added to a membership of this type. There are no student membership discounts. This class defines one instance variable that is used in generating unique ids for family members.

(5) Member.java: a Member object has a MembershipType object associated with it. Members have unique user ids that are equal to their membership id if they are either the only ones on a membership or are the primary member on a family membership. The primary member is the first member added with the family membership. Any additional members added with that same family membership have an additional unique number concatenated to their member ID. For example, if the ID of the primary member is 3470, then the next member added to the membership will have an ID of 34701, followed by 34702, etc.

(6) HealthClub.java: Represents a health club by its name and its members (ArrayList of type Member).

(7) HealthClubGUI.java: Provides a GUI interface for adding members, checking them in, adding family members, making payments, removing members, and filtering members by membership type.

You will be submitting all files except for MembershipType.java and HealthClubGUI.java. You can add testing code to MembershipType, but DO NOT make any other changes to that file. For all other classes, DO NOT make any changes to the instance variables or methods that have already been defined.

Add your name to the start of each file and add header comments on methods and explanatory comments on your code as needed. Some testing code has been provided for you, but you should add more of your own. When your code has been completed, the main interface should look like the image on the next page.

Programming Assignment

BasicMembershipType and FullMembershipType classes

1. Make each of these classes a subclass of the MembershipType class.

2. 1-arg constructor: Passed a boolean value indicating if the member associated with this membership is a student or not. Make use of that value along with the static constants provided in each class.

3. toString() instance method: the String returned must contain the word "basic" for the BasicMembershipType class and "full" for the FullMembershipType class, in your choice of upper or lowercase. The toString() methods used in rendering the above GUI returned "Basic Membership" and "Full Membership," respectively.

FamilyMembershipType

1. Make this class a subclass of the MembershipType class.

2. No-arg constructor: Make use of the static constants provided in this class when implementing the constructor. There are no student discounts with family memberships.

3. toString() instance method: The String returned must contain the word "family" in your choice of upper and lowercase letters.
Member class (8 points)

1. private 4-arg constructor: The header for this constructor has been provided for you. This constructor is for use only in this class for instantiating a new member who has the same membership as a primary member (so for adding a spouse or child after already adding the primary member with a family membership). This constructor must:

• Make use of the other 4-arg constructor already defined in this class. The membership type should be that of the primary member passed as an argument. The charge associated with this new member should be 0.

• Set the relationship instance variable using the mutator method provided for this purpose. Note the constructor is passed an integer for this argument that will have a value of 1 or 2.

• Make use of the updateFamilyMemberID method defined in the FamilyMembershipType class to increase the value of the family member ID by 1. Then concatenate the value returned by this method to the end of the current value of the member userId set by the above call to the public 4-arg constructor.

For example, if the id was set to "0158" by the call to the public constructor, and the updateFamilyMemberID method returns an integer value of 3, then the user ID for the new member should be reset to "01583."

2. createNewMember(String, String, int) instance method: The header for this method has been provided for you. This method is passed three parameters and returns an object of type Member. Its purpose is to create and return a new member who is associated with the same MembershipType object as the member invoking this method. A new Member object should only be created if:

• The Member object invoking this method has a Family Membership type and has a user id whose length is four (so the primary member on the family membership).

If the above criteria are met:

• Make use of the private constructor you added above for instantiating the new member.

• If the new member is a child, then increase the total charge associated with the Member object invoking this method by the additional member fee defined for the Family Membership type.

Return the new Member object created by the method or a value of null if no new Member was created.

The HealthClub class

1. findUserID(String) instance method: This method is passed a String storing a user id and returns a value of type int. If a Member Object with the same user id as that passed to the method is found in the ArrayList of Member objects associated with the invoking HealthClub object (hereafter referred to as the member list or just list), then the position where it was found must be returned.

Otherwise, a value of -1 must be returned. (This method should be useful in writing the code required for methods 4 and 6 below.)

2. add(Member, int) instance method: This method is passed a Member object and an int value representing a position and returns a boolean value. The Member object should be added to that position in the member list if the position is valid. The boolean value returned should indicate whether or not the Member object was added to the list.

3. add(Member) instance method; This method is passed a Member object (note that this and the above method provide an example of method overloading, as opposed to overriding). That object should be added to the end of the list. This method must also return a boolean value indicating if the Member object was added to the list.

4. add(Member, String, String, int) instance method: The header for this method has been provided for you. This method is passed a Member object, a first name, a last name, and a relationship value (1 or 2), in that order. It returns a value of type int. The purpose of this method is to create a new Member object on the same membership as the Member parameter and add it to the list of health
club members. This method must:

• Invoke the createNewMember method you wrote in the Member class using the object referenced by the Member parameter to create a new member on the same membership.

• If a new Member object is returned by the above method call:

- If the new Member object's relationship isn't spouse or it is spouse but there isn't already a spouse on the membership, then add this new member to the list. For full credit, add it immediately after all other Member objects on that membership (as shown in the screenshot). For partial credit, add it immediately after the position in the list of the object stored to the Member parameter.

- If the new Member object relationship is spouse and there is already a spouse on the membership, then for full credit, do not add this Member object to the list. Instead, make use of the updateFamilyMemberID method defined in the FamilyMembershipType class to decrease the value of the family member ID by 1. This adjusts for family member ID having been increased when the new member was created (partial credit if add object in any case).

• This method must return one of the following:

- the position where the new Member object was added to the list (if it was added)

- a value of -1 if the new Member wasn't added because the call to the createNewMember method didn't result in a new Member object being created

- a value of -2 if the new Member wasn't added because it would have resulted in more than one spouse on the primary member's membership

5. getMembersByType(String) instance method: This method is passed a String value. It must return a new ArrayList of type Member containing all Member objects in the list whose membership type description contains the value of the String parameter. Note that you specified descriptions of each membership type in membership toString() methods to include "basic," "full," or "family" in uppercase/lowercase. Your code should be case-insensitive. For example, if passed a value of "Basic" or "BASIC," it should return a list of members with a basic membership type.

6. remove(String) instance method: The String object passed to this method contains a user id. No value is returned by this method. If no member in the ArrayList object has that user id, then no further action needs to be taken. Otherwise:

• Remove that member.

• If that member was a primary member on a family membership, remove all other family members. Note they will all share the same membership.

• If that member was a child on a family membership, reduce the total charge on that membership by the additional fee charged for the child.

Be sure to add testing code to the main method in each class. The GUI interface should be fully functional when you have completed all of the required methods.

Attachment:- Java-Files.zip

Java, Programming

  • Category:- Java
  • Reference No.:- M92793345

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As