Task 1: BetterFitness is a membership-based fitness club in Toronto. Customers can purchase a membership that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 1: BetterFitness is a membership-based fitness club in Toronto. Customers can purchase a membership that provides a fixed number (e.g. 100) of free visits to the club upon registration. When the initial number of visits runs out, they can purchase additional visits as needed. All types of fitness equipment and all fitness classes offered in the club are open for this membership. Please write a Java program (Membership.java) for membership management. The Membership class should have the following public interface: 1. public Membership (String name, int visits): A constructor to set up the member's name and the initial number of visits allowed. The parameter visits is supposed to be positive (if not, initialize the number of visits to 0). 2. public String getName (): An accessor to return the member's name. 3. public int getRemainingVisits (): An accessor to return the number of remaining visits. 4. public boolean isValid (): A method to decide if one's membership is still valid (true if the number of remaining visits is greater than 0; false otherwise). 5. public boolean topUp (int additionalVisits): A method to add additional visits (represented by additionalVisits) to the remainingVisits. Returns true if the top-up succeeds and false otherwise. The top-up succeeds only If the given additionalVisits İs non-negative. 6. public boolean charge (): A method that deducts 1 from the number of remaining visits when the membership is valid. Returns true if the charge succeeds and false otherwise. The charge succeeds only if the membership is valid before charging. 7. public boolean equipmentAllowed (): A method that indicates whether the equipment at the gym is available to this kind of membership. Returns true for now; to be updated in Task 2. 8. public boolean classesAllowed (): A method that indicates whether the fitness classes at the gym are available to this kind of membership. Returns true for now; to be updated in Task 2. Write a tester program Task1 Membership Tester to test the class you have written. Follow the examples given in class (e.g., BankAccountTester), and create an object from the class Membership above. Test the public interface of your class thoroughly (each public method must be tested at least once). For accessor methods, print out the expected return value and the return value of your method (see the BankAccount Tester example) to compare. This tester class is not to be submitted for marking, but it is beneficial for you to make sure your Membership class works as intended. 123456 7 8 9 10 11 ---- A class to test the BankAccount class. */ public class BankAccount Tester { 12 13 14 15 16 17 18 } /** Tests the methods of the BankAccount class. @param args not used */ public static void main(String[] args) { } BankAccount harrys Checking harrys Checking.deposit (2000); harrys Checking.withdraw (500); Program Run: = System.out.println (harrysChecking.getBalance () ); System.out.println("Expected: 1500"); 1500 Expected: 1500 new BankAccount (); Task 1: BetterFitness is a membership-based fitness club in Toronto. Customers can purchase a membership that provides a fixed number (e.g. 100) of free visits to the club upon registration. When the initial number of visits runs out, they can purchase additional visits as needed. All types of fitness equipment and all fitness classes offered in the club are open for this membership. Please write a Java program (Membership.java) for membership management. The Membership class should have the following public interface: 1. public Membership (String name, int visits): A constructor to set up the member's name and the initial number of visits allowed. The parameter visits is supposed to be positive (if not, initialize the number of visits to 0). 2. public String getName (): An accessor to return the member's name. 3. public int getRemainingVisits (): An accessor to return the number of remaining visits. 4. public boolean isValid (): A method to decide if one's membership is still valid (true if the number of remaining visits is greater than 0; false otherwise). 5. public boolean topUp (int additionalVisits): A method to add additional visits (represented by additionalVisits) to the remainingVisits. Returns true if the top-up succeeds and false otherwise. The top-up succeeds only If the given additionalVisits İs non-negative. 6. public boolean charge (): A method that deducts 1 from the number of remaining visits when the membership is valid. Returns true if the charge succeeds and false otherwise. The charge succeeds only if the membership is valid before charging. 7. public boolean equipmentAllowed (): A method that indicates whether the equipment at the gym is available to this kind of membership. Returns true for now; to be updated in Task 2. 8. public boolean classesAllowed (): A method that indicates whether the fitness classes at the gym are available to this kind of membership. Returns true for now; to be updated in Task 2. Write a tester program Task1 Membership Tester to test the class you have written. Follow the examples given in class (e.g., BankAccountTester), and create an object from the class Membership above. Test the public interface of your class thoroughly (each public method must be tested at least once). For accessor methods, print out the expected return value and the return value of your method (see the BankAccount Tester example) to compare. This tester class is not to be submitted for marking, but it is beneficial for you to make sure your Membership class works as intended. 123456 7 8 9 10 11 ---- A class to test the BankAccount class. */ public class BankAccount Tester { 12 13 14 15 16 17 18 } /** Tests the methods of the BankAccount class. @param args not used */ public static void main(String[] args) { } BankAccount harrys Checking harrys Checking.deposit (2000); harrys Checking.withdraw (500); Program Run: = System.out.println (harrysChecking.getBalance () ); System.out.println("Expected: 1500"); 1500 Expected: 1500 new BankAccount ();
Expert Answer:
Answer rating: 100% (QA)
Below is the Java program for the Membership class and a tester program MembershipTester public clas... View the full answer
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Determine the maximum weight of the crate so that the tension developed in any cable does not exceed 450lb. 2 ft 1ft 2 f 2 ft,
-
If the risk-free rate is 4 percent and the risk premium is 6 percent, what is the required return?
-
The variance v is the number of degrees of freedom of a system consisting of r substances in m phases taking part in n chemical reactions. The variance v is obtained by subtracting n constraints from...
-
What is the mirror-image rule?
-
Raven Design is a website design and consulting firm. The firm uses a job cost system, in which each client is a different job. Raven Design traces direct labor, licensing costs, and travel costs...
-
Tl-208 decays through a beta emission and has a half-life of 3.05 minutes. Besides the beta emission, there are several gamma rays associated with the decay and these gamma emissions occur at...
-
It is important to ensure passenger comfort on ships by stabilizing the ship's oscillations due to waves [13]. Most ship stabilization systems use fins or hydrofoils projecting into the water to...
-
Q65. Two identical bodies kept at temperatures 800 K and 200 K act as the hot and the cold reservoirs of an ideal heat engine, respectively. Assume that their heat capacity (C) in Joules/K is...
-
What is the output of the following fragment? int i = 1; int j = 1; while (i < 5) { i++; j = j * 2; } System.out.println(j);
-
Two numbers have a product of 288. The first number is double the second. What equation could be used to find these numbers?
-
What are the policy aims of the changes made to the Residential Tenancies Act?
-
Which one of the following would be considered employment income for Canadian income tax purposes for 2018?
-
A company produced 4,985 gadgets at a cost of $2.07 each. The company sold 4,109 of the gadgets for $14.99 each. What is the closest estimate of the company's profit or loss?
-
1) What multicultural practices would be deemed unethical? 2) Define the culturally encapsulated counselor. Give an example of a counselor whose approach would be seen as culturally encapsulated. 3)...
-
A survey of 70 college freshmen asked whether students planned to take biology, chemistry, or physics during their first year. Use the diagram to answer each question. How many of the surveyed...
-
During year X1, the Nielsen Company reported sales for 2,400 CU and total expenses for 1,800 CU. It has no preexisting deferred tax liability or tax asset. The following information is provided in...
-
Multiple Choice Questions 1. Provisions for risks and liabilities are recorded (a) In the expenses (b) In the revenues (c) In the shareholders equity and liabilities (d) As a contra-asset (e) None of...
-
Multiple Choice Questions Select the right answer (only one possible answers unless otherwise stated). 1 The statement of financial position/balance sheet emphasizes the dynamics of the cash flowing...
-
Cherokee Inc. is a merchandiser that provided the following information: Required: 1. Prepare a traditional income statement. 2. Prepare a contribution format income statement. Amount Number of units...
-
Which of the following statements is true? (You may select more than one answer.) a. Product costs are expensed on the income statement in the period incurred. b. Direct labor is a manufacturing cost...
-
Which of the following statements is true? (You may select more than one answer.) a. Indirect materials and indirect labor are included in manufacturing overhead. b. Examples of selling costs include...
Study smarter with the SolutionInn App