File tree Expand file tree Collapse file tree 7 files changed +51
-23
lines changed
Expand file tree Collapse file tree 7 files changed +51
-23
lines changed Original file line number Diff line number Diff line change 22
33import interfaces .Printable ;
44
5+ import java .util .Scanner ;
6+
57public class App implements Printable {
68
9+
710 public static void main (String [] args ) {
11+ ClientSortingSystem clientSortingSystem = new ClientSortingSystem ();
12+ Scanner scanner = new Scanner (System .in );
13+ App app = new App ();
14+
15+ app .printMainMenu ();
16+ String input = scanner .nextLine ();
17+ int mainOption = Integer .parseInt (input );
818
19+ switch (mainOption ){
20+ case 1 -> System .out .println (clientSortingSystem .getClientList ());
21+ case 2 -> app .printNameSortingOptions ();
22+ case 3 -> app .printIdSortingOptions ();
23+ case 4 -> app .printCredentialsMenu ();
24+ }
925 }
1026}
Original file line number Diff line number Diff line change @@ -59,30 +59,22 @@ public int getIdNumber() {
5959
6060 private static class Credentials { // ДЕЛАТЬ ВЛОЖЕННЫМ ИЛИ НЕТ
6161 private final String phoneNumber ;
62- private final String address ;
6362 private final String email ;
6463
6564 public Credentials (CredBuilder credBuilder ) {
6665 this .phoneNumber = credBuilder .phoneNumber ;
67- this .address = credBuilder .address ;
6866 this .email = credBuilder .email ;
6967 }
7068
7169 public static class CredBuilder {
7270 private String phoneNumber ;
73- private String address ;
7471 private String email ;
7572
7673 public CredBuilder phoneNumber (String phoneNumber ){
7774 this .phoneNumber = phoneNumber ;
7875 return this ;
7976 }
8077
81- public CredBuilder address (String address ){
82- this .address = address ;
83- return this ;
84- }
85-
8678 public CredBuilder email (String email ){
8779 this .email = email ;
8880 return this ;
@@ -97,10 +89,6 @@ public String getPhoneNumber() {
9789 return phoneNumber ;
9890 }
9991
100- public String getAddress () {
101- return address ;
102- }
103-
10492 public String getEmail () {
10593 return email ;
10694 }
Original file line number Diff line number Diff line change 44import java .util .List ;
55
66public class ClientSortingSystem {
7- List <Client > clientList = new ArrayList <>();
7+ private final List <Client > clientList = new ArrayList <>();
8+
9+ public List <Client > getClientList () {
10+ return List .copyOf (clientList );
11+ }
812}
Original file line number Diff line number Diff line change @@ -56,8 +56,7 @@ default void printCredentialsMenu(){
5656 System .out .println (
5757 "Sort clients by:\n " +
5858 "1) Phone numbers\n " +
59- "2) Addresses\n " +
60- "3) Emails\n "
59+ "2) Emails\n "
6160 );
6261 }
6362
@@ -75,14 +74,6 @@ default void printPhoneSortingOptions(){
7574 );
7675 }
7776
78- default void printAddressesSortingOption (){
79- System .out .println (
80- "Sort clients by address:\n " + // так как в одну строку то меньше опций
81- "1) In alphabetic order\n " +
82- "2) Postal code\n "
83- );
84- }
85-
8677 default void printEmailSortingOptions (){
8778 System .out .println (
8879 "Sort clients by email:\n " +
Original file line number Diff line number Diff line change 11package interfaces ;
22
3+ import java .util .List ;
4+
35public interface Sortable {
46
7+ default int [] bubbleIntegerSorting (int [] numbers ) {
8+ boolean isSwaped = true ;
9+ int lastIndex = numbers .length - 1 ;
10+
11+ while (isSwaped ) {
12+ isSwaped = false ;
13+ int range = lastIndex ;
14+
15+ for (int i = 0 ; i < range ; i ++) {
16+ if (numbers [i ] > numbers [i + 1 ]) {
17+ int number1 = numbers [i ];
18+ numbers [i ] = numbers [i + 1 ];
19+ numbers [i + 1 ] = number1 ;
20+ isSwaped = true ;
21+ lastIndex = i + 1 ;
22+ }
23+ }
24+ }
25+ return numbers ;
26+ }
527}
You can’t perform that action at this time.
0 commit comments