This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
Rental each = (Rental) rentals.nextElement(); | |
// add frequent renter points | |
frequentRenterPoints ++; | |
// add bonus for a two day new release rental |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer... | |
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
double thisAmount = 0; | |
Rental each = (Rental) rentals.nextElement(); | |
thisAmount = each.getCharge(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer... | |
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
double thisAmount = 0; | |
Rental each = (Rental) rentals.nextElement(); | |
thisAmount = amountFor(each); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rental... | |
double getCharge() { | |
double result = 0; | |
switch (getMovie().getPriceCode()) { | |
case Movie.REGULAR: | |
result += 2; | |
if (getDaysRented() > 2) | |
result += (getDaysRented() - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer... | |
private double amountFor(Rental aRental) { | |
double result = 0; | |
switch (aRental.getMovie().getPriceCode()) { | |
case Movie.REGULAR: | |
result += 2; | |
if (aRental.getDaysRented() > 2) | |
result += (aRental.getDaysRented() - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double amountFor(Rental aRental) { | |
double result = 0; | |
switch (aRental.getMovie().getPriceCode()) { | |
case Movie.REGULAR: | |
result += 2; | |
if (aRental.getDaysRented() > 2) | |
result += (aRental.getDaysRented() - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: | |
result += aRental.getDaysRented() * 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double amountFor(Rental each) { | |
double thisAmount = 0; | |
switch (each.getMovie().getPriceCode()) { | |
case Movie.REGULAR: | |
thisAmount += 2; | |
if (each.getDaysRented() > 2) | |
thisAmount += (each.getDaysRented() - 2) * 1.5; | |
break; | |
case Movie.NEW_RELEASE: | |
thisAmount += each.getDaysRented() * 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
double thisAmount = 0; | |
Rental each = (Rental) rentals.nextElement(); | |
thisAmount = amountFor(each); | |
// add frequent renter points |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
double thisAmount = 0; | |
Rental each = (Rental) rentals.nextElement(); | |
thisAmount = amountFor(each); | |
// add frequent renter points |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String statement() { | |
double totalAmount = 0; | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
double thisAmount = 0; | |
Rental each = (Rental) rentals.nextElement(); | |
//determine amounts for each line | |
switch (each.getMovie().getPriceCode()) { |