import java.io.*; /* * This method tests that the GroceryItem class is implemented * correctly. It compares the expected values of the name and * price with the values of the name and price that are returned * by getName() and getPrice(). * * See output for more information */ class GroceryItemTester { public static void main (String[] args) { System.out.println("\n\n\n\n\n****************************"); System.out.println(); System.out.println("This tests that the GroceryItem class correctly"); System.out.println("creates objects with the name and price specified"); System.out.println(); // create a GroceryItem object and compare the expected // output with the actual output GroceryItem item1 = new GroceryItem("apple", 3.29); System.out.println("The following two lines should be identical:"); System.out.println(" apple.....3.29"); System.out.println(" " + item1); System.out.println(); // create a GroceryItem object and compare the expected // output with the actual output GroceryItem item2 = new GroceryItem("peach", 10); System.out.println("The following two lines should be identical:"); System.out.println(" peach.....10.0"); System.out.println(" " + item2); System.out.println(); System.out.println("If either pair of lines doesn't match, there is a"); System.out.println("problem with either the constructor, the getName()"); System.out.println("method, or the getPrice() method of the"); System.out.println("GroceryItem class"); } }