FA/PurseTest

From ggc

Jump to: navigation, search

001 package FA;
002 
003 
004 /**
005  * The program tests the methods of the class, Purse.
006  @author Frank Anderson
007  @author Derrick Dixon
008  */
009 public class PurseTest
010 {
011 
012   public static void main(String[] args)
013   {
014     /** model through model6 are purses that contain coins for testing the Purse class. */
015     Purse model  = new Purse();
016     Purse model2 = new Purse();
017     Purse model3 = new Purse();
018     Purse model4 = new Purse();
019     Purse model5 = new Purse();
020     Purse model6 = new Purse();
021 
022     /** Create the original purse */
023     model.addCoin("quarter");
024     model.addCoin("nickel");
025     model.addCoin("dime");
026     model.addCoin("penny");
027 
028     /** model6 is the same as the original model. */
029     model6.addCoin("quarter");
030     model6.addCoin("nickel");
031     model6.addCoin("dime");
032     model6.addCoin("penny");
033 
034     /** purse2 to be added to original purse */
035     model2.addCoin("nickel");
036     model2.addCoin("dime");
037     model2.addCoin("penny");
038 
039     /** purse3 is the same as the orignial purse; same contents, same order.  */
040     model3.addCoin("quarter");
041     model3.addCoin("nickel");
042     model3.addCoin("dime");
043     model3.addCoin("penny");
044 
045     /** purse4 has the same contents as the original but in a different order. */
046     model4.addCoin("quarter");
047     model4.addCoin("nickel");
048     model4.addCoin("penny");
049     model4.addCoin("dime");
050 
051     /** purse5 has one more element than the original purse.   */
052     model5.addCoin("quarter");
053     model5.addCoin("nickel");
054     model5.addCoin("dime");
055     model5.addCoin("penny");
056     model5.addCoin("penny");
057 
058     /** Print the coins in the oringal order of entry.  */
059     System.out.println("The original purse is: ");
060     System.out.println(model);
061     System.out.println();
062 
063     /** Testing  .reverse(). Print the coins in the reverse order of entry.  */
064     System.out.println("The original list in reverse order:");
065     System.out.println(model.reverse());
066     System.out.println();
067 
068     /** Testing .transfer(). Transfer the coins in purse2 to the original purse
069       * and empty the contents of purse2  */
070     System.out.println("Transfer the contents of " +model2.toString());
071     System.out.println(" to  "+model.toString());
072     model.transfer(model2);
073     System.out.println(model.toString());
074     System.out.println("The contens of model2 should now be empty. Model2=");
075     System.out.println(model2.toString());
076     System.out.println();
077 
078     /** Testing  .sameContents(). Check to see if the contents are the same.
079       *  model and model6 are the same.*/
080     System.out.println("The contents of model3 and the original model6 should be the same.");
081     System.out.println(" model3 = "+model3.toString());
082     System.out.println(" model6 = "+model6.toString());
083     System.out.println(model3.sameContents(model6));
084     System.out.println("Expected result above: true");
085     System.out.println();
086 
087     /** Testing  .sameContents().Check to see if the contents are the same.
088       * model and model4 are the same. */
089     System.out.println("The contents of model4 and the original model should NOT be the same.");
090     System.out.println("original purse = "+model.toString());
091     System.out.println("       purse 4 = "+model4.toString());
092     System.out.println(model6.sameContents(model4));
093     System.out.println("Expected result above: false");
094     System.out.println();
095 
096     /** Testing .sameCoins(). Check to see if the coin counts are the same.
097       * model3 and model4 have different order.*/
098     System.out.println("Check to see if the coins in the purse are the same.");
099     System.out.println(model3.toString()+" has the same coins as");
100     System.out.println(model4.toString());
101     System.out.println(model3.sameCoins(model4));
102     System.out.println("Expected result above: true");
103     System.out.println();
104 
105     /** Testing .sameCoins(). Check to see if the two purses have the same contents,
106       * regardless of order.*/
107     System.out.println("Check to see if the coins in the purse are the same.");
108     System.out.println("original purse: "+model6.toString());
109     System.out.println("       purse5 :" + model5.toString());
110     System.out.println(model6.sameCoins(model5));
111     System.out.println("Expected results above: false.");
112 
113   }
114 }


Download/View FA/PurseTest.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter