Compare commits
No commits in common. "0c4e5d3e895435c80c6729bf3ea7f3f8228a3ca7" and "4fce8c914c25217c0eaabc45be4f9574c4f0932a" have entirely different histories.
0c4e5d3e89
...
4fce8c914c
|
@ -15,7 +15,6 @@ public class Lab3 {
|
||||||
wordList.clear();
|
wordList.clear();
|
||||||
wordList.addAll(wordSet);
|
wordList.addAll(wordSet);
|
||||||
wordList.sort(String::compareToIgnoreCase);
|
wordList.sort(String::compareToIgnoreCase);
|
||||||
wordList.sort((o1, o2) -> o1.compareToIgnoreCase(o2));
|
|
||||||
|
|
||||||
for (String element : wordList) {
|
for (String element : wordList) {
|
||||||
System.out.println(element);
|
System.out.println(element);
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package IO_24._02_Бондаренко_Тарас_Андрійович.lab6;
|
|
||||||
|
|
||||||
public class Comfort extends Tariff {
|
|
||||||
public Comfort(String name, int price, int customers) {
|
|
||||||
super(name, price, customers);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package IO_24._02_Бондаренко_Тарас_Андрійович.lab6;
|
|
||||||
|
|
||||||
public class Economy extends Tariff {
|
|
||||||
|
|
||||||
public Economy(String name, int price, int customers) {
|
|
||||||
super(name, price, customers);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package IO_24._02_Бондаренко_Тарас_Андрійович.lab6;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class Lab6 {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Comfort tariff1 = new Comfort("Comfort", 100, 5000);
|
|
||||||
Economy tariff2 = new Economy("Economy", 25, 10000);
|
|
||||||
Optimal tariff3 = new Optimal("Optimal", 300, 50000);
|
|
||||||
|
|
||||||
Tariff[] tariffs = {tariff1, tariff2, tariff3};
|
|
||||||
int sum = 0;
|
|
||||||
System.out.println("Тарифи мобільної мобільної компанії:");
|
|
||||||
for (int i = 0; i < tariffs.length; i++) {
|
|
||||||
System.out.printf("\t%d. %s%n", i + 1, tariffs[i].getName());
|
|
||||||
sum += tariffs[i].getCustomers();
|
|
||||||
}
|
|
||||||
System.out.println("\nЗагальна кількість користувачів: " + sum + ";");
|
|
||||||
|
|
||||||
System.out.println("\nТарифи мобільної компанії відсортовані за вартістю:");
|
|
||||||
Arrays.sort(tariffs, Comparator.comparing(Tariff::getPrice));
|
|
||||||
for (int i = 0; i < tariffs.length; i++) {
|
|
||||||
System.out.printf("\t%d. %s%n", i + 1, tariffs[i]);
|
|
||||||
}
|
|
||||||
System.out.println("\nВведіть діапазон цін, в якому бажаєте підібрати тариф: ");
|
|
||||||
|
|
||||||
Scanner scan = new Scanner(System.in);
|
|
||||||
System.out.print("\tМінімальна ціна: ");
|
|
||||||
int minSum = scan.nextInt();
|
|
||||||
System.out.print("\tМаксимальна ціна: ");
|
|
||||||
int maxSum = scan.nextInt();
|
|
||||||
scan.close();
|
|
||||||
int n2 = 0;
|
|
||||||
|
|
||||||
System.out.println("\nПідібрані тарифи: ");
|
|
||||||
for (int i = 0; i < tariffs.length; i++) {
|
|
||||||
if (minSum <= tariffs[i].getPrice() && tariffs[i].getPrice() <= maxSum) {
|
|
||||||
System.out.printf("\t%d. %s%n", i + 1, tariffs[i]);
|
|
||||||
n2 += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (n2 == 0) {
|
|
||||||
System.out.println("\tНе знайдено тарифів в заданому діапазоні цін;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package IO_24._02_Бондаренко_Тарас_Андрійович.lab6;
|
|
||||||
|
|
||||||
public class Optimal extends Tariff {
|
|
||||||
public Optimal(String name, int price, int customers) {
|
|
||||||
super(name, price, customers);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package IO_24._02_Бондаренко_Тарас_Андрійович.lab6;
|
|
||||||
|
|
||||||
public class Tariff {
|
|
||||||
private final String name;
|
|
||||||
private final int price;
|
|
||||||
private final int customers;
|
|
||||||
|
|
||||||
public Tariff(String name, int price, int customers) {
|
|
||||||
this.name = name;
|
|
||||||
this.price = price;
|
|
||||||
this.customers = customers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPrice() {
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCustomers() {
|
|
||||||
return customers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Тариф " + name + ", коштує " + price + " грн.";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue