Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. @Test
  2. public void testStatementRegularMovieOnly() {
  3. // regular movies cost $2.00 for the first 2 days, and $1.50/day thereafter
  4. // a rental earns 1 frequent-renter point no matter how many days
  5. Customer johnDoe = new Customer("John Doe");
  6.  
  7. johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 1));
  8. assertEquals("Rental Record for John Doe\n" +
  9. "\tSlumdog Millionaire\t3.0\n" +
  10. "Amount owed is 3.0\n" +
  11. "You earned 1 frequent renter points",
  12. johnDoe.statement());
  13.  
  14.  
  15. johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 2));
  16. assertEquals("Rental Record for John Doe\n" +
  17. //the first movie rental above
  18. "\tSlumdog Millionaire\t3.0\n" +
  19. //the current movie rental
  20. "\tSlumdog Millionaire\t6.0\n" +
  21. "Amount owed is 9.0\n" +
  22. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  23. "You earned 3 frequent renter points",
  24. johnDoe.statement());
  25.  
  26.  
  27. johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 3));
  28. assertEquals("Rental Record for John Doe\n" +
  29. //the first movie rental above
  30. "\tSlumdog Millionaire\t3.0\n" +
  31. //the second movie rental above
  32. "\tSlumdog Millionaire\t6.0\n" +
  33. // the current movie rental
  34. "\tSlumdog Millionaire\t9.0\n" +
  35. "Amount owed is 18.0\n" +
  36. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  37. "You earned 5 frequent renter points",
  38. johnDoe.statement());
  39. }
  40.  
  41. @Test
  42. public void testStatementChildrensMovieOnly() {
  43. // childrens' movies cost $1.50 for the first 3 days, and $1.25/day thereafter
  44. // a rental earns 1 frequent-renter point no matter how many days
  45. Customer johnDoeJr = new Customer("Johnny Doe, Jr.");
  46.  
  47.  
  48. johnDoeJr.addMovieRental(new MovieRental(mulan, 1));
  49. assertEquals("Rental Record for Johnny Doe, Jr.\n" +
  50. "\tMulan\t1.5\n" +
  51. "Amount owed is 1.5\n" +
  52. "You earned 1 frequent renter points",
  53. johnDoeJr.statement());
  54.  
  55.  
  56. johnDoeJr.addMovieRental(new MovieRental(mulan, 2));
  57. assertEquals("Rental Record for Johnny Doe, Jr.\n" +
  58. //the first movie rental above
  59. "\tMulan\t1.5\n" +
  60. //the current movie rental
  61. "\tMulan\t1.5\n" +
  62. "Amount owed is 3.0\n" +
  63. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  64. "You earned 2 frequent renter points",
  65. johnDoeJr.statement());
  66.  
  67.  
  68. johnDoeJr.addMovieRental(new MovieRental(mulan, 3));
  69. assertEquals("Rental Record for Johnny Doe, Jr.\n" +
  70. //the first movie rental above
  71. "\tMulan\t1.5\n" +
  72. //the second movie rental above
  73. "\tMulan\t1.5\n" +
  74. // the current movie rental
  75. "\tMulan\t1.5\n" +
  76. "Amount owed is 4.5\n" +
  77. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  78. "You earned 3 frequent renter points",
  79. johnDoeJr.statement());
  80. }
  81.  
  82. @Test
  83. public void testStatementNewReleaseOnly() {
  84. // new releases cost $3.00/day
  85. // a rental earns 1 frequent-renter point 1 day; 2 points for 2 or more days
  86. Customer janeDoe = new Customer("Jane Doe");
  87.  
  88.  
  89. janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 1));
  90. assertEquals("Rental Record for Jane Doe\n" +
  91. "\tThe Man Who Knew Too Much\t2.0\n" +
  92. "Amount owed is 2.0\n" +
  93. "You earned 1 frequent renter points",
  94. janeDoe.statement());
  95.  
  96. janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 2));
  97. assertEquals("Rental Record for Jane Doe\n" +
  98. //the first movie rental above
  99. "\tThe Man Who Knew Too Much\t2.0\n" +
  100. //the current movie rental
  101. "\tThe Man Who Knew Too Much\t2.0\n" +
  102. "Amount owed is 4.0\n" +
  103. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  104. "You earned 2 frequent renter points",
  105. janeDoe.statement());
  106.  
  107.  
  108.  
  109. janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 3));
  110. assertEquals("Rental Record for Jane Doe\n" +
  111. //the first movie rental above
  112. "\tThe Man Who Knew Too Much\t2.0\n" +
  113. //the second movie rental above
  114. "\tThe Man Who Knew Too Much\t2.0\n" +
  115. // the current movie rental
  116. "\tThe Man Who Knew Too Much\t3.5\n" +
  117. "Amount owed is 7.5\n" +
  118. //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
  119. "You earned 3 frequent renter points",
  120. janeDoe.statement());
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement