Assignment 1 Java 2 International class
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. import java.util.*;
  2. public class Cat extends Pet {
  3. private boolean allergic;
  4. public Cat(){
  5. }
  6. public Cat(int petId, String name, double weight, Date dob, double accumulatedDose, boolean allergic){
  7. super(petId, name, weight, dob, accumulatedDose);
  8. this.allergic = allergic;
  9. }
  10. //Setter
  11. public void setAllergic(boolean allergic){
  12. this.allergic = allergic;
  13. }
  14. //Getter
  15. public boolean getAllergic(){
  16. return this.allergic;
  17. }
  18. public double getDose(){
  19. if ( getAccumulatedDose() > 500) {
  20. return 0;
  21. // }else if(getAllergic() == true){
  22. // return 0;
  23. // }else if( findAge() >3 && weight > 0.5){
  24. // return 7+0.61* getWeight();
  25. }else{
  26. return 0.81 * getWeight();
  27. }
  28. }
  29. public String toString(){
  30. return "petID=" + getPetId() +
  31. ", name='" + getName() + '\'' +
  32. ", weight=" + getWeight() +
  33. // ", dob=" + VetClinicConsole.dateToStr(getDob()) +
  34. // ", accumulatedDose=" + getAccumulatedDose() +
  35. ",allergic='" + allergic + '\'';
  36. }
  37. }