Date private int day private int month private
- Slides: 28
Date private int day; // יום private int month; // חודש private int year; // שנה public Date(int day, int month, int year) public Date(Date other) // בנאי העתקה + פעולות גישה public boolean equals(Date other) // פעולה שמחזירה אמת אם שני התאריכים זהים public String to. String() 4 נתונה המחלקה : הבאה
Child private String name; // ה / שם הילד String id; // מספר תז char gender; // מגדר Date birth. Day; // תאריך לידה public Child(String name, String id, char gender, Date birth. Day) public Child(Child other) // פעולה בונה מעתיקה + פעולות גישה public boolean is. Same. Birth. Day(Child other) 5 נתונה המחלקה : הבאה
Family. Name: “Cohen” num. Kids: 4 arr: null null 7 null
Family : Family כתבו שתי פעולות בונות למחלקה . Family מקבלת שם משפחה ובונה עצם מטיפוס. א . Family מקבלת את כל התכונות ובונה עצם מטיפוס. ב public Family(String family. Name, int num. Kids, Child[] arr) { this. family. Name = family. Name; this. num. Kids = num. Kids; this. arr = new Child[15]; for(int i=0; i<arr. length; i++) this. arr[i] = new Child(arr[i]); } 9
Family שמקבלת מגדר ומחזירה את מספר Children. By. Gender הוסיפו פעולה . הילדים במשפחה שזה המגדר שלהם public int Children. By. Gender(char g) { int counter=0; for(int i=0; i< this. num. Kids; i++){ if(this. arr[i]. get. Gender() == g) counter++; } return counter; } 12
עם שלושת הילדים Family בתכנית הראשית צרו עצם מטיפוס. 1. שהוגדרו בשיעור הקודם Child c 1 = new Child("Judith", "111" , 'F', new Date(15, 9, 2007)); Child c 2 = new Child("Nurith", "222" , 'F', new Date(10, 12, 2010)); Child c 3 = new Child("Hava", "333" , 'F', new Date(14, 5, 2013)); Family f = new Family("Caspi"); f. add. Child(c 1); f. add. Child(c 2); f. add. Child(c 3); 14
כמה בנות , התכנית הראשית תציג את ילדי המשפחה ותאריכי לידתם. 3. וכמה בנים במשפחה System. out. print("There are: "); System. out. print(f. Children. By. Gender('F')); System. out. print(" Girls, and "); System. out. print(f. Children. By. Gender('M')); System. out. print(" Boys in the " + f. get. Family. Name() + " family. "); : מה יוצג על המסך 16
Clock private int hour; // שעות private int minutes; // דקות private int seconds; // שניות public Clock(int hour, int minutes, int seconds) + פעולות גישה 18 נתונה המחלקה : הבאה
Point private int x; private int y; public Point(int x, int y) public Point(Point other) // בנאי העתקה + פעולות גישה public double distance(Point other) // פעולה שמחזירה את המרחק בין שתי הנקודות public String to. String() 21 נתונה המחלקה : הבאה
public static double lowest. Point(Point[] arr) { double min = arr[0]. get. Y(); מערך של נקודות : טענת כניסה double time. Of. Min = arr[0]. get. X(); הפעולה תחזיר את נקודת : טענת יציאה הזמן בה ביקרו התלמידים במקום הנמוך ביותר בטיול for(int i=0; i<arr. length; i++){ if(arr[i]!= null && arr[i]. get. Y() < min){ min = arr[i]. get. Y(); time. Of. Min = arr[i]. get. X(); } } return time. Of. Min; } 24
- Sum0
- Day 1 day 2 day 3 day 4
- Inheritance calculator
- Public void drawsquare(int x, int y, int len)
- Divideint
- Int max(int x int y)
- Sidereal vs synodic month
- Nisan abib
- Day 1 day 2 day 817
- Ex dividend date
- Dividend policy example
- 아두이노 const int
- 7팩토리얼
- Max int
- Interface myinterface int foo(int x)
- Int main int num 4
- Mainint
- Int main(int argc, char** argv)
- Voidswap
- #include stdio.h void main()
- Int f(int n)
- New day and date always begins in the _________ of idl
- World environment day 2021
- L
- Public class person private string name
- Private int
- A { private int x; public a( val) { x = val; } }
- Class bucket int capacity
- One day he's coming oh glorious day