Question

In: Computer Science

I am stuck on this Java problem: Create an Animal class with: Attributes Age Rabies Vaccination...

I am stuck on this Java problem:

Create an Animal class with:

  • Attributes
    • Age
    • Rabies Vaccination Status
    • Name
    • Owner Name
  • A constructor to set values
  • Getters and Setters for all private attributes
  • A toString method that gives the data of all attributes

Create a Dog Class

  • Attributes
    • Distemper Vaccination Status
  • A constructor to set values in sub class
  • A constructor to set values in sub and super class
  • Getters and Setters for private attributes
  • A toString method that overrides the super class and adds Distemper Vaccination Status
  • A speak method that outputs "bark".

Create a Cat Class

  • Attributes
    • Feline Leukemia Vaccination Status
    • Declawed Status
  • A constructor to set values in sub class
  • A constructor to set values in sub and super class
  • Getters and Setters for private attributes
  • A toString method that overrides the super class and adds Feline Leukemia Vaccination Status
  • A speak method that outputs "Meow".

Solutions

Expert Solution

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________


// Animal.java

public class Animal {
   //Declaring instance variables
   private int age;
   private boolean RabiesVaccinationStatus;
   private String name;
   private String ownerName;

   //Zero argumented constructor
   public Animal() {
  
   }
   //Parameterized constructor
   public Animal(int age, boolean rabiesVaccinationStatus, String name,
           String ownerName) {
       this.age = age;
       RabiesVaccinationStatus = rabiesVaccinationStatus;
       this.name = name;
       this.ownerName = ownerName;
   }

   // getters and setters
   public int getAge() {
       return age;
   }

   public void setAge(int age) {
       this.age = age;
   }

   public boolean isRabiesVaccinationStatus() {
       return RabiesVaccinationStatus;
   }

   public void setRabiesVaccinationStatus(boolean rabiesVaccinationStatus) {
       RabiesVaccinationStatus = rabiesVaccinationStatus;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getOwnerName() {
       return ownerName;
   }

   public void setOwnerName(String ownerName) {
       this.ownerName = ownerName;
   }

   //toString method is used to display the contents of an object inside it
   public String toString() {
       return "Age :" + age + ", Rabies Vaccination Status :"
               + RabiesVaccinationStatus + ", Name :" + name
               + ", Owner Name :" + ownerName;
   }

}
______________________

// Dog.java

public class Dog extends Animal {
   //Declaring instance variables
   private boolean distemperVaccinationStatus;

   //Parameterized constructor
   public Dog(boolean distemperVaccinationStatus) {
       this.distemperVaccinationStatus = distemperVaccinationStatus;
   }

   //Parameterized constructor
   public Dog(int age, boolean rabiesVaccinationStatus, String name,
           String ownerName, boolean distemperVaccinationStatus) {
       super(age, rabiesVaccinationStatus, name, ownerName);
       this.distemperVaccinationStatus = distemperVaccinationStatus;
   }

   // getters and setters
   public boolean isDistemperVaccinationStatus() {
       return distemperVaccinationStatus;
   }

   public void setDistemperVaccinationStatus(boolean distemperVaccinationStatus) {
       this.distemperVaccinationStatus = distemperVaccinationStatus;
   }

   //toString method is used to display the contents of an object inside it
   public String toString() {
       return "Dog :"+super.toString() + " Distemper Vaccination Status :"
               + distemperVaccinationStatus;
   }

   public void speak()
   {
       System.out.println("bark");
   }

}
___________________________

// Cat,.java

public class Cat extends Animal {
   //Declaring instance variables
   private boolean felineLeukemiaVaccinationStatus;
   private boolean declawedStatus;

   //Parameterized constructor
   public Cat(boolean felineLeukemiaVaccinationStatus, boolean declawedStatus) {
       this.felineLeukemiaVaccinationStatus = felineLeukemiaVaccinationStatus;
       this.declawedStatus = declawedStatus;
   }
   //Parameterized constructor
   public Cat(int age, boolean rabiesVaccinationStatus, String name,
           String ownerName, boolean felineLeukemiaVaccinationStatus,
           boolean declawedStatus) {
       super(age, rabiesVaccinationStatus, name, ownerName);
       this.felineLeukemiaVaccinationStatus = felineLeukemiaVaccinationStatus;
       this.declawedStatus = declawedStatus;
   }

   // getters and setters
   public boolean isFelineLeukemiaVaccinationStatus() {
       return felineLeukemiaVaccinationStatus;
   }

   public void setFelineLeukemiaVaccinationStatus(
           boolean felineLeukemiaVaccinationStatus) {
       this.felineLeukemiaVaccinationStatus = felineLeukemiaVaccinationStatus;
   }

   public boolean isDeclawedStatus() {
       return declawedStatus;
   }

   public void setDeclawedStatus(boolean declawedStatus) {
       this.declawedStatus = declawedStatus;
   }

   //toString method is used to display the contents of an object inside it
   public String toString() {
       return "Cat :"+super.toString() + " Feline Leukemia Vaccination Status :"
               + felineLeukemiaVaccinationStatus + ", Declawed Status :"
               + declawedStatus;
   }

   public void speak()
   {
       System.out.println("Meow");
   }

}
_____________________________

// Test.java

public class Test {

   public static void main(String[] args) {
Dog d=new Dog(2,true,"Max","Kevin",true);
  
Cat c=new Cat(1,true,"Kitty","Bobby",true,true);

System.out.println(d);
d.speak();
System.out.println(c);
c.speak();
   }

}

___________________________

Output:

Dog :Age :2, Rabies Vaccination Status :true, Name :Max, Owner Name :Kevin Distemper Vaccination Status :true

bark
Cat :Age :1, Rabies Vaccination Status :true, Name :Kitty, Owner Name :Bobby Feline Leukemia Vaccination Status :true, Declawed Status :true

Meow

_______________Could you plz rate me well.Thank You


Related Solutions

Java ArrayList Parking Ticket Simulator, Hello I am stuck on this problem where I am asked...
Java ArrayList Parking Ticket Simulator, Hello I am stuck on this problem where I am asked to calculate the sum of all fines in the policeOfficer class from the arraylist i created. I modified the issueParking ticket method which i bolded at the very end to add each issued Parking ticket to the arrayList, i think thats the right way? if not please let me know. What I dont understand how to do is access the fineAmountInCAD from the arrayList...
I am stuck on this problem and I am not sure what the solution is. In...
I am stuck on this problem and I am not sure what the solution is. In C Write item.h and item.c. In item.h, typedef a struct (of type t_item) which contains the following information: t_item: char name[MAX_ITEM_NAME_STRING]; char description[MAX_ITEM_DESCRIPTION_STRING]; Make sure that MAX_ITEM_NAME_STRING and MAX_ITEM_DESCRIPTION_STRING are defined with suitable sizes in your item.h. Typical values are, 25 and 80, respectively. Add the following interface definition to item.h: int item_load_items(t_item items[], int max_items, char *filename); Returns the number of objects loaded...
In java: -Create a class named Animal
In java: -Create a class named Animal
This is a question for my problem-solving class. I am really stuck and I can't see...
This is a question for my problem-solving class. I am really stuck and I can't see much of a pattern so I would appreciate if someone could draw out for each thief and explain the pattern to get the answer for 40 thieves! Question: Forty thieves, all different ages, steal a huge pile of identical gold coins and must decide how to divide them up. They settle on the following procedure. The youngest divides the coins among the thieves however...
Hi! I am in an intro level Finance course and I am stuck on this problem....
Hi! I am in an intro level Finance course and I am stuck on this problem. Any help would be greatly appreciated. I am deciding on opening a restaurant. I was able to scrape together some capital from friends and family, but I must pay them back in 4 years at 12% per annum. I figure that it will cost me $165,000 to start up with rent, deposits, equipment, salaries, chicken, basil, rice, etc. for the first year, but I...
Please use java to answer the below question. (i) Create a class Pencil with the attributes...
Please use java to answer the below question. (i) Create a class Pencil with the attributes brand (which is a string) and length (an integer) which are used to store the brand and length of the ruler respectively. Write a constructor Pencil (String brand, int length) which assigns the brand and length appropriately. Write also the getter/setter methods of the two attributes. Save the content under an appropriate file name. Copy the content of the file as the answers. (ii)...
I am stuck on the following problem please and it has to be in python! 1)...
I am stuck on the following problem please and it has to be in python! 1) Initially, create a list of the following elements and assign the list to a variable "thing". "Mercy", "NYU", "SUNY", "CUNY" 2) print the list above 3) add your last name to the list 4) print the list 5) add the following elements as a nested list to the list: "iPhone", "Android" 6) print the list 7) add the following list to the end of...
This is for my finance class and I am a bit stuck. We're asked to use...
This is for my finance class and I am a bit stuck. We're asked to use the Delta hedging formula (i.e. how much stock to hold) for the multiperiod binomial model to confirm that a financial derivative paying the stock price at time t=N (i.e. V_N = S_N) must be priced with V_0 = S_0 today.
Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose:...
Description: Create a class in Python 3 named Animal that has specified attributes and methods. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Animal that has the following attributes and methods and is saved in the file Animal.py. Attributes __animal_type is a hidden attribute used to indicate the animal’s type. For example: gecko, walrus, tiger, etc. __name is a...
*in Java 1.Create a card class with two attributes, suit and rank. 2.In the card class,...
*in Java 1.Create a card class with two attributes, suit and rank. 2.In the card class, create several methods: a. createDeck – input what type of deck (bridge or pinochle) is to be created and output an array of either 52 or 48 cards. b.shuffleDeck – input an unshuffled deck array and return a shuffled one. + Create a swap method to help shuffle the deck c. countBridgePoints – inputs a 13-card bridge ‘hand’-array and returns the number of high-card...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT