Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void testStatementRegularMovieOnly() {
- // regular movies cost $2.00 for the first 2 days, and $1.50/day thereafter
- // a rental earns 1 frequent-renter point no matter how many days
- Customer johnDoe = new Customer("John Doe");
- johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 1));
- assertEquals("Rental Record for John Doe\n" +
- "\tSlumdog Millionaire\t3.0\n" +
- "Amount owed is 3.0\n" +
- "You earned 1 frequent renter points",
- johnDoe.statement());
- johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 2));
- assertEquals("Rental Record for John Doe\n" +
- //the first movie rental above
- "\tSlumdog Millionaire\t3.0\n" +
- //the current movie rental
- "\tSlumdog Millionaire\t6.0\n" +
- "Amount owed is 9.0\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 3 frequent renter points",
- johnDoe.statement());
- johnDoe.addMovieRental(new MovieRental(slumdogMillionaire, 3));
- assertEquals("Rental Record for John Doe\n" +
- //the first movie rental above
- "\tSlumdog Millionaire\t3.0\n" +
- //the second movie rental above
- "\tSlumdog Millionaire\t6.0\n" +
- // the current movie rental
- "\tSlumdog Millionaire\t9.0\n" +
- "Amount owed is 18.0\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 5 frequent renter points",
- johnDoe.statement());
- }
- @Test
- public void testStatementChildrensMovieOnly() {
- // childrens' movies cost $1.50 for the first 3 days, and $1.25/day thereafter
- // a rental earns 1 frequent-renter point no matter how many days
- Customer johnDoeJr = new Customer("Johnny Doe, Jr.");
- johnDoeJr.addMovieRental(new MovieRental(mulan, 1));
- assertEquals("Rental Record for Johnny Doe, Jr.\n" +
- "\tMulan\t1.5\n" +
- "Amount owed is 1.5\n" +
- "You earned 1 frequent renter points",
- johnDoeJr.statement());
- johnDoeJr.addMovieRental(new MovieRental(mulan, 2));
- assertEquals("Rental Record for Johnny Doe, Jr.\n" +
- //the first movie rental above
- "\tMulan\t1.5\n" +
- //the current movie rental
- "\tMulan\t1.5\n" +
- "Amount owed is 3.0\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 2 frequent renter points",
- johnDoeJr.statement());
- johnDoeJr.addMovieRental(new MovieRental(mulan, 3));
- assertEquals("Rental Record for Johnny Doe, Jr.\n" +
- //the first movie rental above
- "\tMulan\t1.5\n" +
- //the second movie rental above
- "\tMulan\t1.5\n" +
- // the current movie rental
- "\tMulan\t1.5\n" +
- "Amount owed is 4.5\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 3 frequent renter points",
- johnDoeJr.statement());
- }
- @Test
- public void testStatementNewReleaseOnly() {
- // new releases cost $3.00/day
- // a rental earns 1 frequent-renter point 1 day; 2 points for 2 or more days
- Customer janeDoe = new Customer("Jane Doe");
- janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 1));
- assertEquals("Rental Record for Jane Doe\n" +
- "\tThe Man Who Knew Too Much\t2.0\n" +
- "Amount owed is 2.0\n" +
- "You earned 1 frequent renter points",
- janeDoe.statement());
- janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 2));
- assertEquals("Rental Record for Jane Doe\n" +
- //the first movie rental above
- "\tThe Man Who Knew Too Much\t2.0\n" +
- //the current movie rental
- "\tThe Man Who Knew Too Much\t2.0\n" +
- "Amount owed is 4.0\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 2 frequent renter points",
- janeDoe.statement());
- janeDoe.addMovieRental(new MovieRental(theManWhoKnewTooMuch, 3));
- assertEquals("Rental Record for Jane Doe\n" +
- //the first movie rental above
- "\tThe Man Who Knew Too Much\t2.0\n" +
- //the second movie rental above
- "\tThe Man Who Knew Too Much\t2.0\n" +
- // the current movie rental
- "\tThe Man Who Knew Too Much\t3.5\n" +
- "Amount owed is 7.5\n" +
- //notice it is the 1 point from before and 2 points for 2 or more days for the current movie.
- "You earned 3 frequent renter points",
- janeDoe.statement());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement