|
|
1.1 root 1: // Department.m
2: //
3: // Created on Wed Feb 15 09:50:50 GMT-0800 1995 by NeXT EOModeler.app Version 77
4:
5: #import "Department.h"
6: #import "Employee.h"
7:
8: @implementation Department
9:
10: - (Employee *)lowestPaidEmployee
11: // return the lowest paid employee. We might want to do this via a query too
12: {
13: // the server rather than by traversing the objects here...
14: NSEnumerator *emps = [toEmployees objectEnumerator];
15: Employee *emp, *lowestEmp = nil;
16: while (emp = [emps nextObject]) {
17: if (!lowestEmp || ([emp salary] < [lowestEmp salary]))
18: lowestEmp = emp;
19: }
20: return lowestEmp;
21: }
22:
23: - (NSString *)validateEmployee:(Employee *)emp
24: {
25: // Lets say no employee can make more than 10 times the lowest paid
26: // employee in his or her department
27: Employee *lowest = [self lowestPaidEmployee];
28: double limit = [lowest salary] * 10.0;
29:
30: if ([emp salary] > limit)
31: return [NSString stringWithFormat:@"Salary exceeds departmental limit of %.2f", limit];
32: return nil;
33: }
34:
35: - (void)dealloc
36: {
37: [departmentName autorelease];
38: [toEmployees autorelease];
39: [super dealloc];
40: }
41:
42: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.