Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. package lesson2;
  2.  
  3. /**
  4. * Created by Viktoriya.D on 6/14/2017.
  5. */
  6. class Animals {
  7. static private long counter;
  8. private double age = 0;
  9. private String name;
  10. private String gender = "It";
  11. protected int feet;
  12. protected String colorsEyes []= {"",""};
  13.  
  14. Animals(double age, String name, String gender) {
  15. counter++;
  16. this.age = age;
  17. this.name = name;
  18. if (gender.equals("f")) this.gender = gender;
  19. else if (gender.equals("m")) this.gender = gender;
  20. }
  21.  
  22. public double getAge() {
  23. return age;
  24. }
  25.  
  26. public static long getCounter() {
  27. return counter;
  28. }
  29.  
  30. void voice() {
  31. for (int i = 0; i < age; i++) {
  32. System.out.println("I`m");
  33. }
  34. }
  35. /*String gender (String gender){
  36.  
  37. }*/
  38. protected void setFeet(int feet){
  39. this.feet=feet;
  40. }
  41. protected int getFeet(){
  42. return this.feet;
  43. }
  44. double heightAnimal(double weight){
  45. double h;
  46. if (this.age<1){
  47. h=this.age*weight;
  48. } else if (this.gender.equals("f")){
  49. h=weight*2;
  50. } else h=weight*3;
  51. return h;
  52. }
  53.  
  54. protected void setColorsEyes(String eye1) {
  55. this.colorsEyes[1] = eye1;
  56. }
  57. protected void setColorsEyes(String eye1,String eye2) {
  58. this.colorsEyes[0] = eye1;
  59. this.colorsEyes[1] = eye2;
  60. }
  61. protected String[] getColorsEyes(){
  62. return this.colorsEyes;
  63. }
  64.  
  65. @Override
  66. public String toString() {
  67. return "I'm Animals :"+ "\n" + "My age=" + age +"," + "\n"+ "My name is " + name +", " +'\n' + "My gender=" + gender ;
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement