Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- * >>>>>> TESTER for class ShoppingList --- This code is complete <<<<<<
- *
- * --------------- Below is the output from this tester ----------------
- * Shopping list = apples
- * Shopping list = apples, spam
- * Shopping list = apples, spam, broccoli
- * Shopping list = apples, broccoli
- * Shopping list = apples, broccoli
- * Shopping list = apples
- * Shopping list = apples
- * Shopping list = apples, Twinkies
- * Shopping list = Twinkies
- * Shopping list =
- * Shopping list = Cheez Whiz
- * Shopping list = Cheez Whiz, bread
- * Shopping list = Cheez Whiz
- * Shopping list = Cheez Whiz
- *****************************************************************/
- public class ShoppingListTester
- {
- public static void check(ShoppingList list, String check) {
- System.out.print("shopping list = "+list);
- if (list.toString().equals(check)) {
- System.out.println(" <<CORRECT>>");
- }
- else {
- System.out.println(" <<ERROR!>>");
- }
- }
- public static void main(String args[])
- {
- ShoppingList Creech = new ShoppingList("");
- Creech.addItem("apples");
- check(Creech,"apples");
- Creech.addItem("spam");
- check(Creech,"apples, spam");
- Creech.addItem("broccoli");
- check(Creech,"apples, spam, broccoli");
- Creech.removeItem("spam");
- check(Creech,"apples, broccoli");
- Creech.addItem("apples");
- check(Creech,"apples, broccoli");
- Creech.removeItem("broccoli");
- check(Creech,"apples");
- Creech.removeItem("chicken");
- check(Creech,"apples");
- Creech.addItem("Twinkies");
- check(Creech,"apples, Twinkies");
- Creech.removeItem("apples");
- check(Creech,"Twinkies");
- Creech.removeItem("Twinkies");
- check(Creech,"");
- Creech.addItem("Cheez Whiz");
- check(Creech,"Cheez Whiz");
- Creech.addItem("bread");
- check(Creech,"Cheez Whiz, bread");
- Creech.removeItem("bread");
- check(Creech,"Cheez Whiz");
- Creech.removeItem("Twinkies");
- check(Creech,"Cheez Whiz");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement