Advertisement
mmayoub

TestBucket.java

Jan 28th, 2023
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package proj27012023;
  2.  
  3. import java.util.Scanner;
  4.  
  5. import unit4.bucketLib.Bucket;
  6.  
  7. public class TestBucket {
  8.  
  9.     public static void main(String[] args) {
  10.         Bucket b1 = new Bucket(10, "B1");
  11.  
  12.         b1.fill(7);
  13.  
  14.         Bucket b2 = new Bucket(3, "B2");
  15.  
  16.         b1.pourInto(b2);
  17.         b2.pourInto(b1);
  18.  
  19.         Scanner in = new Scanner(System.in);
  20.         int capacity;
  21.         double amount;
  22.  
  23.         System.out.print("Enter capacity: ");
  24.         capacity = in.nextInt();
  25.         System.out.print("Enter amount: ");
  26.         amount = in.nextDouble();
  27.  
  28.         Bucket b3 = new Bucket(capacity, "BBB");
  29.         b3.fill(amount);
  30.  
  31.         System.out.println("empty=" + (b3.getCapacity() - b3.getCurrentAmount()));
  32.  
  33.     }
  34.  
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement