diff --git a/ticket/Test.java b/ticket/Test.java index 503ccec..1eb1dd1 100644 --- a/ticket/Test.java +++ b/ticket/Test.java @@ -11,7 +11,7 @@ public class Test { Scanner sc = new Scanner(System.in); while (continueBuy) { System.out.print("Please enter your name: "); - name = sc.next(); + name = sc.nextLine(); System.out.print("Please enter your payment: "); payment = sc.nextInt(); Thread consumer = new Thread(ts, name + "-" + payment); @@ -22,8 +22,9 @@ public class Test { e.printStackTrace(); } System.out.println("Do you want to continue buying tickets? Y: Yes, N: No"); - continueBuy = sc.next().equalsIgnoreCase("Y"); + continueBuy = "Y".equalsIgnoreCase(sc.next()); + sc.nextLine(); } sc.close(); } -} \ No newline at end of file +} diff --git a/ticket/TicketSeller.java b/ticket/TicketSeller.java index 8faa684..0c3a07b 100644 --- a/ticket/TicketSeller.java +++ b/ticket/TicketSeller.java @@ -71,4 +71,4 @@ public class TicketSeller implements Runnable { } } } -} \ No newline at end of file +}