-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew Text Document.TXT
More file actions
105 lines (83 loc) · 2.59 KB
/
New Text Document.TXT
File metadata and controls
105 lines (83 loc) · 2.59 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Vehicle[] list = new Vehicle[5];
list[0] = new Vehicle("Mercedes", "Benz", 2018, 100.1f);
list[1] = new ElVehicle("Nissan", "Leaf", 2015, 0.0f, 15000);
list[2] = new Vehicle("BMW", "F1", 2019, 200.2f);
list[3] = new ConVehicle("Opel", "Zafira", 2000, 0.5f, "dizel");
list[4] = new Vehicle("Lada", "Niva", 1987, 5.5f);
*/
// ArrayList<Vehicle> list = new ArrayList<>();
/* list.add(new Vehicle("Mercedes", "Benz", 2017, 100.1f));
list.add(new ElVehicle("Nissan", "Leaf", 2015, 0.0f, 15000));
list.add(new Vehicle("BMW", "F1", 2019, 200.2f));
list.add(new ConVehicle("Opel", "Zafira", 2000, 0.5f, "dizel"));
list.add(new ConVehicle("Opel", "F1", 1999, 0.5f, "dizel"));
list.add(new Vehicle("Lada", "Niva", 1987, 5.5f));
*/
// Comparator<Vehicle> byModel = (Vehicle v1, Vehicle v2) -> v1.model.compareTo(v2.model);
// list.sort(byModel.thenComparing(byYear));
// addVehicle(list, new Vehicle("Toyota", "A6", 2001, 1.1f));
// findLatestVehicle(list);
// findByModel(list,"Leaf");
// for(int i=0; i<3; i++) {
// list.add(readConsole());
// }
//
// Comparator<Vehicle> byYear = (Vehicle v1, Vehicle v2) -> Integer.compare(v2.year, v1.year);
// list.sort(byYear);
//
// for (Vehicle x : list ) {
// System.out.println(x);
// }
// }
//
// public static Vehicle readConsole() {
//
// Scanner scan = new Scanner(System.in);
//
// System.out.print("Vuvedi marka: ");
// String brand = scan.nextLine();
// System.out.print("Vuvedi model: ");
// String model = scan.nextLine();
// System.out.print("Vuvedi godina: ");
// int year = scan.nextInt();
// System.out.print("Vuvedi cons: ");
// float cons = scan.nextFloat();
//
// return new Vehicle(brand, model, year, cons);
//
// }
/* public static void addVehicle(ArrayList<Vehicle> list, Vehicle v) {
boolean isAdded = false;
for (int i=0; i<list.size(); i++) {
if(list.get(i).year < v.year) {
list.add(i, v);
isAdded=true;
break;
}
}
if(!isAdded) list.add(v);
}
*/
/* public static void findLatestVehicle(ArrayList<Vehicle> arrList) {
int position = 0;
for (int i=0; i<arrList.size()-1; i++) {
if (arrList.get(i).year < arrList.get(i+1).year) {
position = i + 1;
}
}
System.out.println(arrList.get(position));
}
*/
/* public static void findByModel(ArrayList<Vehicle> arrList, String model) {
boolean isFound = false;
for (int i=0; i<arrList.size()-1; i++) {
if (arrList.get(i).model.equals(model)) {
System.out.println(arrList.get(i));
isFound = true;
}
}
if (!isFound) {
System.out.print("Not Found");
}
}
*/