concept ctfixedlease in category ios

appears as: CTFixedLease
Objective-C Fundamentals

This is an excerpt from Manning's book Objective-C Fundamentals.

6.7.3. Creating CTFixedLease as a subclass of CTLease

You now make another CTLease subclass called CTFixedLease so you can represent a lease as having a different set of terms rather than some periodic set amount. This type of lease will have a fixed time and a fixed amount, and it won’t recur. The header of CTFixedLease is similar to that of CTLease but in this case has ivars: totalRental and numberOfWeeks. Insert the code from the following listing into the header file.

Listing 6.15. CTFixedLease.h
#import "CTLease.h" @interface CTFixedLease : CTLease { float totalRental; int numberOfWeeks; } @property(nonatomic) float totalRental; @property(nonatomic) int numberOfWeeks; + (CTLease *)fixedTermLeaseWithPrice:(float)totalRental forWeeks:(int)numberOfWeeks; @end

The implementation of CTFixedLease is similar to that of CTPeriodicLease. You set both instance variables for the class and return an autoreleased instance. You also make sure the description method prints out both of your instance messages in the description. Use the code in the following listing for the implementation of CTFixedLease’s main file.