FileDocCategorySizeDatePackage
Rental.javaAPI DocExample2314Thu Oct 13 14:57:38 BST 2005com.samscdrental.model

Rental

public class Rental extends Object implements Serializable

Title: Sams CD Rental Store

Description:

Copyright: Copyright (c) 2004

Company:

author
Ken Pugh
version
1.0

Fields Summary
private static final long
serialVersionUID
private Customer
theCustomer
private Timestamp
theStartTime
private Timestamp
theEndTime
private Dollar
theRentalFee
private int
theBaseRentalPeriodDays
Constructors Summary
public Rental(Customer aCustomer, int baseRentalPeriodDays, Dollar rentalFee)
Rental

param
theCustomer Customer
param
baseRentalPeriodDays int

 

	       	 
	     
				     
	
		theCustomer = aCustomer;
		theBaseRentalPeriodDays = baseRentalPeriodDays;
		theRentalFee = rentalFee;
	
Methods Summary
public voidcheckIn()
checkIn

		theEndTime = new Timestamp();
	
public intgetBaseRentalPeriodDays()

		return theBaseRentalPeriodDays;
	
public CustomergetCustomer()

		return theCustomer;
	
public TimestampgetDueTime()

		return theStartTime.addDays( theBaseRentalPeriodDays );
	
public TimestampgetEndTime()

		return theEndTime;
	
public DollargetRentalFee()

		return theRentalFee;
	
public TimestampgetStartTime()

		return theStartTime;
	
public booleanisLateReturn()
isLateReturn

return
boolean

		if ( theEndTime == null )
		{
			// Not yet returned, but they are asking about it anyway
			Timestamp now = new Timestamp();
			return now.differenceInDays( theStartTime ) >
				 theBaseRentalPeriodDays ;
		}
		else
		{
			// See if was late
			return theEndTime.differenceInDays( theStartTime ) >
				 theBaseRentalPeriodDays;
		}
	
public booleanisOverdue()
isOverdue

return
boolean

		if ( theEndTime == null )
		{
			// Not yet returned
			Timestamp now = new Timestamp();
			return now.differenceInDays( theStartTime ) >
				 theBaseRentalPeriodDays ;
		}
		else
		{
			// Not overdue, since it has been returned
			return false;
		}

	
public voidsetStartTime(Timestamp startTime)

		theStartTime = startTime;