Advertisement
korobushk

liquid containers NEW MAIN

May 5th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner scan = new Scanner(System.in);
  3.  
  4. Container container = new Container();
  5. Container container2 = new Container();
  6.  
  7. while (true) {
  8. System.out.println("First"+container);
  9. System.out.println("Second:"+container2);
  10. System.out.print("> ");
  11. System.out.println();
  12. String input = scan.nextLine();
  13. if (input.equals("quit")) {
  14. break;
  15. }
  16.  
  17. String[] partsOfInput = input.split(" ");
  18. input = partsOfInput[0];
  19. int amount = Integer.valueOf(partsOfInput[1]);
  20.  
  21. if (input.equals("add") && amount > 0) {
  22. container.add(amount);
  23. }
  24.  
  25. if (input.equals("move") && amount > 0) {
  26.  
  27. container2.move(amount);
  28. container.remove(amount);
  29.  
  30.  
  31. }
  32.  
  33. if (input.equals("remove") && amount > 0) {
  34. container2.remove(amount);
  35.  
  36. }
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement