Dido09

Cat2

Jan 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package smth;
  2. import java.util.Scanner;
  3. public class Cat {
  4.  
  5. String name;
  6.  
  7. private String color;
  8. public String getName() {
  9.  
  10. return this.name;
  11. }
  12. public void setName(String name) {
  13.  
  14. this.name = name;
  15.  
  16. }
  17. public String getColor() {
  18.  
  19. return this.color;
  20.  
  21. }
  22. public void setColor(String color) {
  23.  
  24. this.color = color;
  25.  
  26. }
  27. public Cat() {
  28.  
  29. this.name = "Unnamed";
  30.  
  31. this.color = "gray";
  32. }
  33. public Cat(String name, String color) {
  34.  
  35. this.name = name;
  36.  
  37. this.color = color;
  38. }
  39. public void sayMiau() {
  40.  
  41. System.out.printf("Cat %s said: Miauuuuuu!%n", name);
  42.  
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment