Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
75 lines (58 loc) · 2.98 KB

File metadata and controls

75 lines (58 loc) · 2.98 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.ArrayList;
import java.util.Arrays;
public class MainClass {
public static void main(String[] args) {
// Exercise 1
//Создаем ссылку и объект типа gen и все упоковываем
GenericClass<String> catsNames = new GenericClass<String>(new String[]{"Lulu", "Tom"});
GenericClass<Integer> catsAges = new GenericClass<Integer>(new Integer[]{4, 5});
GenericClass<Double> catsWieghts = new GenericClass<Double>(new Double[]{5.5, 7.1});
//Смотрим на тип
System.out.println("\nLook at the type of the array. We have: ");
catsNames.showType();
catsAges.showType();
catsWieghts.showType();
//Создаем листы
System.out.println("\nCreate the array list with old positions of elements");
catsNames.createArrayList();
catsAges.createArrayList();
catsWieghts.createArrayList();
//Меняем местами
System.out.println("\nCreate the array with new positions of elements");
catsNames.changePositionOfElementsInArray();
catsAges.changePositionOfElementsInArray();
catsWieghts.changePositionOfElementsInArray();
// Exercise 2
//Создаем коробку для яблок и создаем яблоки
Box<Apple> appleBox = new Box<>();
Apple a1 = new Apple();
Apple a2 = new Apple();
Apple a3 = new Apple();
// Кидаем яблоки в коробку
appleBox.addFruit(a1);
appleBox.addFruit(a2);
appleBox.addFruit(a3);
// Вес коробки с яблоками
System.out.println("\nThe total weight of the apple box is " + appleBox.getTotalWeight());
//Создаем коробку для апельсинов и создаем апельсины
Box<Orange> orangeBox = new Box<>();
Orange o1 = new Orange();
Orange o2 = new Orange();
Orange o3 = new Orange();
// Кидаем апельсины в коробку
orangeBox.addFruit(o1);
orangeBox.addFruit(o2);
orangeBox.addFruit(o3);
// Вес коробки с апельсинами
System.out.println("The total weight of the orange box is " + orangeBox.getTotalWeight());
// Сравниваем коробки
System.out.println("The result of matching boxes is " + appleBox.compare(orangeBox));
// Создаем новую пустую коробку и закидываем туда яблоки
Box<Apple> newAppleBox = new Box<>();
appleBox.replaceAllFruitsToOtherBox(newAppleBox);
//Создадим еще одно яблоко и закинем его в новую коробку и потом посмотрим вес
Apple a4 = new Apple();
newAppleBox.addFruit(a4);
System.out.println("The total weight of the new apple box is " + newAppleBox.getTotalWeight());
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.