Objects
Objects
Cascader Operator
Equality Type 1
Equality Type 2
Student List
Student HashSet
Task 1
Quyidagicha Dog klass yarating va Dog klass orqali yaratilgan object larni tengligini “operator” orqali ta`minlang. Bu misolda object lar teng deyiladi qachonki ham kuchuklarning nomi va yoshi teng bo`lsa.
Dog dog1 = new Dog("tuffy", 5);
Dog dog2 = new Dog("tuffy", 5);
Task 2
1- masalani endi object tengligini tekshirishda foydalaniladigan “comparable” orqali hal qiling.
Task 3
Quyidagi 2 ta buyurtmalarni magazinda mavjud yoki mavjud emasligini aniqlaydigan klass va programma yozing.
List magazin = [
new Product("8271", "Monitor"),
new Product("8662", "iPad"),
new Product("0979", "Mac Book"),
new Product("1231", "iPod"),
new Product("8877", "iPhone")
];
Product product1 = Product("0979", "Mac Book Pro");
Product product2 = Product("8665", "iPad 12.9");
Enumeration
Enumeration
Enum For 1
Enum For 2
Time Enum
Error Class
Task 1
Quyidagicha Dog klass yarating va Dog klass orqali yaratilgan object larni tengligini “operator” orqali ta`minlang. Bu misolda object lar teng deyiladi qachonki ham kuchuklarning nomi va yoshi teng bo`lsa.
Dog dog1 = new Dog("tuffy", 5);
Dog dog2 = new Dog("tuffy", 5);
Task 2
Hafta kunlari uchun Enum yarating va undan foydalanib dayIsLike() degan metod yarating. Bu metod enum ning qiymatlariga qarab quyidagilardan birini chiqarsin.
Mondays are bad.
Fridays are better.
Weekends are best.
Midweek days are so-so
Task 3
Direction ni ko`rsatadigan enum yarating. (EAST, WEST, NORTH, SOUTH). Hamda getMyDirection method orqali quyidagi lardan birini chop qiladigan kod yozing.
In East Direction
In West Direction
In North Direction
In South Direction
Dostları ilə paylaş: |