File:  [NeXTSTEP 3.3 examples] / Examples / EnterpriseObjects / EOController / PeopleDemo_oracle / Department.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:49 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

/* Department.m
 * A simple enterprise object.
 * 
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 *
 * Written by Mai Nguyen, NeXT Developer Support
 */

#import "Department.h"
#import "strings.h"


@implementation Department

- init 
{
	[super init];
	// You can add additional intialization here.
	return self;
}

- (void)dealloc
{
	[DepartmentName autorelease];
	[FacilityLocation autorelease];
	[toEmployee autorelease];
	[super dealloc];
   
}


// Accessor methods 

- (void) setDepartmentName:(NSString *)newName
{
	[DepartmentName autorelease];
	DepartmentName = [newName retain];
	return;
}

- (NSString *)DepartmentName { return DepartmentName; }

- (void) setDeptId:(int)newId
{
	DeptId = newId;
	return; 
} 

- (int)DeptId { return DeptId; }


- (void) setLocationId:(int)newLocation
{
	LocationId = newLocation;
	return;	 
} 

- (int)LocationId { return LocationId; }

- (void)setToFacility:value
{
    // A TO-ONE relationship.
    [toFacility autorelease];
    toFacility = [value retain];
    return;
}
- toFacility { return toFacility; }

- (void)setFacilityLocation:(NSString *)value
{
    [FacilityLocation autorelease];
    FacilityLocation = [value retain];
    return;
}
- (NSString *)FacilityLocation { return FacilityLocation; }

- (void)setToEmployee:(NSArray *)value
{
    // A TO-MANY relationship.
    [toEmployee autorelease];
    toEmployee = [value retain];
    return;
}
- (NSArray *)toEmployee { return toEmployee; }
 
- (void) setAverageSalary:(int)aSalary
{
	averageSalary = aSalary;
	return;
}

- (int)averageSalary
{
	int			i;
	unsigned	count = 0;
	id			anEmployee, value;
	int 		totalSalaries = 0;
	
	averageSalary = 0; 
	if (toEmployee) {
		count = [toEmployee count];
		totalSalaries = 0;
		for (i = 0; i < count; i++) {
			anEmployee = [toEmployee objectAtIndex:i];
			value = [anEmployee objectForKey:@"Salary"];
				// skip Salary with Null values
			if  (![value isEqual:[EONull null]])
			totalSalaries += [[anEmployee objectForKey:@"Salary"] intValue];
			} 
	}
	if (count > 0)
 		averageSalary = totalSalaries/count;
		
	return averageSalary;
}


@end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.