Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - חלק ראשי אבא
- package Main;
- public class Cat {
- protected int mouthtouche;
- protected String name, color;
- public Cat(int mouthtouche , String name, String color) {
- this.mouthtouche = mouthtouche ;
- this.name = name;
- this.color =color;
- }
- @Override
- public String toString() {
- return "Cat mouthtouche=" + mouthtouche + ", name=" + name
- + ", color=" + color;
- }
- }
- חלק ראשון בן
- package Main;
- public class StreetCat extends Cat {
- protected int fightes;
- public StreetCat (int mouthtouche ,int fightes ,String name ,String color )
- {
- super(mouthtouche,name ,color);
- this.fightes=fightes;
- }
- @Override
- public String toString() {
- return "StreetCat fightes=" + fightes + ", mouthtouche=" + mouthtouche
- + ", name=" + name + ", color=" + color;
- }
- }
- חלק שני בן
- package Main;
- public class SiamiCat extends Cat {
- protected String food;
- public SiamiCat(int mouthtouche, String food, String name, String color) {
- super(mouthtouche, name, color);
- this.food = food;
- }
- @Override
- public String toString() {
- return "SiamiCat food=" + food + ", mouthtouche=" + mouthtouche
- + ", name=" + name + ", color=" + color;
- }
- }
- חלק של הטסט
- package Main;
- import java.util.Scanner;
- public class Tester {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- StreetCat cat1 = new StreetCat(0, 0, null,null);
- SiamiCat cat2 = new SiamiCat(0,null,null,null );
- cat1=new StreetCat(s.nextInt(),s.nextInt(),s.next(),s.next());
- cat2=new SiamiCat(s.nextInt(),s.next(),s.next(),s.next());
- System.out.println(cat1 + "\n" + cat2 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement