import javax.swing.*;
/**
 * AirFillShopTester tests an AirFillShop
 */
public class AirFillShopTester {
  
  /**
   * Create some AirFillShops and test their methods
   */
  public static void test() {
    // Try out first constructor
    String s1= JOptionPane.
      showInputDialog("Enter a price, a comma, and a name");
    double d1= Double.parseDouble(s1.substring(0, s1.indexOf(',')));
    String nm= s1.substring(s1.indexOf(',') + 2);
    AirFillShop afs2= new AirFillShop(d1, nm);
    
    // Try out the second constructor
    s1= JOptionPane.
      showInputDialog("Enter a price, a comma, and a name");
    AirFillShop afs1= new AirFillShop(s1);
    
    // Check out toString() for both shops
    System.out.println("afs1: " + afs1);
    System.out.println("afs2: " + afs2);
    
    // Check the initial income (should be zero)
    System.out.println("Income now: " + AirFillShop.getTotalIncome());
    
    // Sell some air, then check income
    System.out.println("37.93 buys " +
                       afs1.sellAir(37.93) + " litres" +
                       " from " + afs1.getName() + " which gives " +
                       afs1.getMLPerDollar() + " mL per dollar.");
    System.out.println("Income now: " + AirFillShop.getTotalIncome());
    
    // Sell some more air from the other shop, then check income
    System.out.println("55.25 buys " +
                       afs2.sellAir(55.25) + " litres "
                         + " from " + afs2.getName() + " which gives " +
                       afs2.getMLPerDollar() + " mL per dollar.");
    System.out.println("Income now: " + AirFillShop.getTotalIncome());
  }
}
