Question
Classes: Create a class called Cat. The Cat class should have the following public interface: public Cat(String name, String breed, int age): A constructor to
Classes: Create a class called Cat. The Cat class should have the following public interface: public Cat(String name, String breed, int age): A constructor to set up the cats name, breed, and age. public String getName(): An accessor to return the cats name. public String getBreed(): An accessor to return the cats breed. public int getAge(): An accessor to return the cats age.
-------------------------------------------------------------------------------------------------------------------------------
Create a class called Membership. The Membership class should have the following public interface: public Membership(String name, int visits): A constructor to set up the members 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). public String getName(): An accessor to return the members name. public int getRemainingVisits(): An accessor to return the number of remaining visits. public boolean isValid(): A method to decide if ones membership is still valid. The method will return true if the number of remaining visits is greater than 0; false otherwise. 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 is non-negative. 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.
-------------------------------------------------------------------------------------------------------------------------------
Create a class called CatTester to test the Cat class. Instantiate a Cat object and test every method in the class thoroughly. Ensure that any data you print to the console is clearly labelled and described.
-------------------------------------------------------------------------------------------------------------------------------
Create a class called MembershipTester to test the Membership class. Instantiate a Membership object and test every method in the class thoroughly. Ensure that any data you print to the console is clearly labelled and described.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started