Update lab4

This commit is contained in:
kxtzzl 2023-04-06 00:22:53 +03:00 committed by GitHub
parent 511422ad6c
commit 1f0c160216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

6
lab4
View File

@ -44,7 +44,7 @@ public class Lab4 {
int C11 = 2430 % 11; int C11 = 2430 % 11;
System.out.println("\n ----------------------------------------------------------------------------------------------------------"); System.out.println("\n ----------------------------------------------------------------------------------------------------------");
System.out.println(" C17 = " + C11 + ", So, the task is: Define the student class, which consists of at least 5 fields."); System.out.println(" C11 = " + C11 + ", So, the task is: Define the student class, which consists of at least 5 fields.");
System.out.println(" ----------------------------------------------------------------------------------------------------------"); System.out.println(" ----------------------------------------------------------------------------------------------------------");
Student[] students = { Student[] students = {
@ -80,7 +80,7 @@ public class Lab4 {
System.out.println("Invalid sort order! Please enter 'asc' or 'desc'."); System.out.println("Invalid sort order! Please enter 'asc' or 'desc'.");
continue; continue;
} }
Comparator<Student> comparator = null; Comparator<Student> comparator = null;
switch (field) { switch (field) {
case "greed book": case "greed book":
@ -103,7 +103,7 @@ public class Lab4 {
comparator = comparator.reversed(); comparator = comparator.reversed();
} }
Arrays.sort(students, comparator); Arrays.sort(students, comparator);
System.out.println("\nSorted by " + field + " (in " + order + "ending order):"); System.out.println("\nSorted by " + field + " (in " + order + "ending order):");
System.out.println(String.format("%n%-15s | %-20s | %-4s | %-4s | %-10s", "Greed book", "Name", "Age", "GPA", " Faculty")); System.out.println(String.format("%n%-15s | %-20s | %-4s | %-4s | %-10s", "Greed book", "Name", "Age", "GPA", " Faculty"));
System.out.println("----------------------------------------------------------------"); System.out.println("----------------------------------------------------------------");