|
|
Sample Programs from NeXSTEP 3.3
// Department.m
//
// Created on Wed Feb 15 09:50:50 GMT-0800 1995 by NeXT EOModeler.app Version 77
#import "Department.h"
#import "Employee.h"
@implementation Department
- (Employee *)lowestPaidEmployee
// return the lowest paid employee. We might want to do this via a query too
{
// the server rather than by traversing the objects here...
NSEnumerator *emps = [toEmployees objectEnumerator];
Employee *emp, *lowestEmp = nil;
while (emp = [emps nextObject]) {
if (!lowestEmp || ([emp salary] < [lowestEmp salary]))
lowestEmp = emp;
}
return lowestEmp;
}
- (NSString *)validateEmployee:(Employee *)emp
{
// Lets say no employee can make more than 10 times the lowest paid
// employee in his or her department
Employee *lowest = [self lowestPaidEmployee];
double limit = [lowest salary] * 10.0;
if ([emp salary] > limit)
return [NSString stringWithFormat:@"Salary exceeds departmental limit of %.2f", limit];
return nil;
}
- (void)dealloc
{
[departmentName autorelease];
[toEmployees autorelease];
[super dealloc];
}
@end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.