לפניך ממשק המחלקה Button המייצגת כפתור. לכפתור שלוש תכונות: מספר הרשום עליו num, גודל הכפתור size וצבע הכפתור color.
public Button(int num)public Button(int num)public Button(int num, int size, String color)public Button(int num, int size, string color)public int getSize()public int GetSize()public void addToSize(int x)public void AddToSize(int x)public boolean isSameSize(Button other)public bool IsSameSize(Button other)ממש במחלקה Button את הפעולה הבונה Button(int num).
ממש במחלקה Button את הפעולה המגדילה את גודל הכפתור ב־x addToSize(x)
ממש במחלקה Button את הפעולה הבודקת אם גודל הכפתור other זהה לגודל הכפתור הנוכחי (isSameSize / IsSameSize).
עקוב אחר ביצוע קטע הפעולה, ורשום את הפלט שיתקבל. לכל עצם רשום את השמות של כל התכונות שלו, את הערכים של כל התכונות ואת השינויים שהיו בהם.
Java:
java1Button a1 = new Button(1, 12, "red"); 2Button a2 = new Button(2, 12, "green"); 3Button a3 = new Button(3, 12, "blue"); 4Button a4 = new Button(4); 5a1.addToSize(2); 6a4.addToSize(9); 7if (a1.isSameSize(a3)) 8 System.out.println("***"); 9if (a4.isSameSize(a1)) 10 System.out.println("$$$"); 11if (a2.isSameSize(a3)) 12 System.out.println("###");
C#:
csharp1Button a1 = new Button(1, 12, "red"); 2Button a2 = new Button(2, 12, "green"); 3Button a3 = new Button(3, 12, "blue"); 4Button a4 = new Button(4); 5a1.AddToSize(2); 6a4.AddToSize(9); 7if (a1.IsSameSize(a3)) 8 Console.WriteLine("***"); 9if (a4.IsSameSize(a1)) 10 Console.WriteLine("$$$"); 11if (a2.IsSameSize(a3)) 12 Console.WriteLine("###");
לפניך ממשק המחלקה Button המייצגת כפתור. לכפתור שלוש תכונות: מספר הרשום עליו num, גודל הכפתור size וצבע הכפתור color.
public Button(int num)public Button(int num)public Button(int num, int size, String color)public Button(int num, int size, string color)public int getSize()public int GetSize()public void addToSize(int x)public void AddToSize(int x)public boolean isSameSize(Button other)public bool IsSameSize(Button other)ממש במחלקה Button את הפעולה הבונה Button(int num).
ממש במחלקה Button את הפעולה המגדילה את גודל הכפתור ב־x addToSize(x)
ממש במחלקה Button את הפעולה הבודקת אם גודל הכפתור other זהה לגודל הכפתור הנוכחי (isSameSize / IsSameSize).
עקוב אחר ביצוע קטע הפעולה, ורשום את הפלט שיתקבל. לכל עצם רשום את השמות של כל התכונות שלו, את הערכים של כל התכונות ואת השינויים שהיו בהם.
Java:
java1Button a1 = new Button(1, 12, "red"); 2Button a2 = new Button(2, 12, "green"); 3Button a3 = new Button(3, 12, "blue"); 4Button a4 = new Button(4); 5a1.addToSize(2); 6a4.addToSize(9); 7if (a1.isSameSize(a3)) 8 System.out.println("***"); 9if (a4.isSameSize(a1)) 10 System.out.println("$$$"); 11if (a2.isSameSize(a3)) 12 System.out.println("###");
C#:
csharp1Button a1 = new Button(1, 12, "red"); 2Button a2 = new Button(2, 12, "green"); 3Button a3 = new Button(3, 12, "blue"); 4Button a4 = new Button(4); 5a1.AddToSize(2); 6a4.AddToSize(9); 7if (a1.IsSameSize(a3)) 8 Console.WriteLine("***"); 9if (a4.IsSameSize(a1)) 10 Console.WriteLine("$$$"); 11if (a2.IsSameSize(a3)) 12 Console.WriteLine("###");