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
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
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... | |
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 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
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
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 += each.getFrequentRenterPoints(); | |
//show figures for this 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() { | |
int frequentRenterPoints = 0; | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
Rental each = (Rental) rentals.nextElement(); | |
frequentRenterPoints += each.getFrequentRenterPoints(); | |
//show figures for this rental | |
result += "\t" + each.getMovie().getTitle()+ "\t" + |
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() { | |
Enumeration rentals = _rentals.elements(); | |
String result = "Rental Record for " + getName() + "\n"; | |
while (rentals.hasMoreElements()) { | |
Rental each = (Rental) rentals.nextElement(); | |
//show figures for this rental | |
result += "\t" + each.getMovie().getTitle()+ "\t" + | |
String.valueOf(each.getCharge()) + "\n"; | |
} |
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 htmlStatement() { | |
Enumeration rentals = _rentals.elements(); | |
String result = "<H1>Rentals for <EM>" + getName() + "</EM></H1><P>\n"; | |
while (rentals.hasMoreElements()) { | |
Rental each = (Rental) rentals.nextElement(); | |
//show figures for each rental | |
result += each.getMovie().getTitle()+ ": " + | |
String.valueOf(each.getCharge()) + "<BR>\n"; | |
} | |
//add footer lines |