Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class called Pet . The Pet class will have a constructor which will take a String name , String type , double

1. Create a class called Pet . The Pet class will have a constructor which will take a String name , String type , double price , and an int age . These variables will be passed in through a driver program and should be set to global variables to store their values . 2. The Pet class should have 4 get methods to return the value of these four variables . These methods should accept no parameters . 3. There should be a global boolean variable called isAdult . This value is set in the constructor through a private method called checkAdult . This method takes no parameters and returns true if the pet's age is 4 or over . If the pet's age is less than 4 the value is false . The type of pet is also changed only if it is a " dog " or " cat " . The new name will be " puppy " and " kitten " respectfully . 4. There should be a method called superSale . This method accepts a percentage ( double ) and lowers the price of the pet by this amount . Assume the information is entered correctly . 5. There should be a method called isCute . This method accepts no parameters and returns a String . If the pet is a puppy or kitten , it should return the String " SUPER CUTE ! " , if the types are not puppy or kitten , it should return " CUTE ! " 6. There should be a method called happyBirthday which will increase the pet's age by one . If the type is a puppy or kitten and the age goes to 4 , the type should be changed to dog and cat respectfully . 7. Make a driver program that will run your code . Create 3 pets and display their information . Name : Bob Name : Charlotte Name : Norm Type : Cat Type : puppy Type : snake price : 300 price : 500 price : 50 age : 12 age : 1 age : 2 CUTE ! SUPER CUTE ! CUTE !

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

6 y + 1 4 y + 1 2

Answered: 1 week ago