Advertisement
eliRubinshtin

java cat class

Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. - חלק ראשי אבא
  2.  
  3. package Main;
  4.  
  5.  
  6. public class Cat {
  7. protected int mouthtouche;
  8. protected String name, color;
  9.  
  10. public Cat(int mouthtouche , String name, String color) {
  11. this.mouthtouche = mouthtouche ;
  12. this.name = name;
  13. this.color =color;
  14. }
  15.  
  16. @Override
  17. public String toString() {
  18. return "Cat mouthtouche=" + mouthtouche + ", name=" + name
  19. + ", color=" + color;
  20. }
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. חלק ראשון בן
  29. package Main;
  30.  
  31. public class StreetCat extends Cat {
  32. protected int fightes;
  33.  
  34. public StreetCat (int mouthtouche ,int fightes ,String name ,String color )
  35. {
  36. super(mouthtouche,name ,color);
  37. this.fightes=fightes;
  38. }
  39.  
  40. @Override
  41. public String toString() {
  42. return "StreetCat fightes=" + fightes + ", mouthtouche=" + mouthtouche
  43. + ", name=" + name + ", color=" + color;
  44. }
  45.  
  46. }
  47.  
  48.  
  49. חלק שני בן
  50.  
  51. package Main;
  52.  
  53. public class SiamiCat extends Cat {
  54. protected String food;
  55.  
  56. public SiamiCat(int mouthtouche, String food, String name, String color) {
  57. super(mouthtouche, name, color);
  58. this.food = food;
  59. }
  60.  
  61. @Override
  62. public String toString() {
  63. return "SiamiCat food=" + food + ", mouthtouche=" + mouthtouche
  64. + ", name=" + name + ", color=" + color;
  65. }
  66.  
  67. }
  68.  
  69.  
  70. חלק של הטסט
  71.  
  72.  
  73. package Main;
  74.  
  75. import java.util.Scanner;
  76.  
  77. public class Tester {
  78.  
  79. public static void main(String[] args) {
  80. Scanner s = new Scanner(System.in);
  81.  
  82.  
  83. StreetCat cat1 = new StreetCat(0, 0, null,null);
  84. SiamiCat cat2 = new SiamiCat(0,null,null,null );
  85.  
  86. cat1=new StreetCat(s.nextInt(),s.nextInt(),s.next(),s.next());
  87. cat2=new SiamiCat(s.nextInt(),s.next(),s.next(),s.next());
  88. System.out.println(cat1 + "\n" + cat2 );
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement