CSC407/ECE450 Assignment 1b Sample Solution

plan.dom
Class Company

java.lang.Object
  |
  +--plan.dom.Company

public class Company
extends java.lang.Object

A software company that builds products.


Field Summary
private  java.util.HashMap lnkCustomer
           
private  java.util.HashMap lnkEmployee
           
private  java.util.HashMap lnkSoftware
           
 
Constructor Summary
Company()
           
 
Method Summary
 Software getSoftware(java.lang.String name)
          Returns the software product of the given name.
 Customer lookupOrCreateCustomer(java.lang.String name)
          Lookup a Customer and return it or return a new one if not found.
 Employee lookupOrCreateEmployee(java.lang.String name)
          Lookup an Employee and return it or return a new one if not found.
 Software lookupOrCreateSoftware(java.lang.String name)
          Lookup a Software product and return it or return a new one if not found.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

lnkSoftware

private java.util.HashMap lnkSoftware

lnkEmployee

private java.util.HashMap lnkEmployee

lnkCustomer

private java.util.HashMap lnkCustomer
Constructor Detail

Company

public Company()
Method Detail

lookupOrCreateCustomer

public Customer lookupOrCreateCustomer(java.lang.String name)
Lookup a Customer and return it or return a new one if not found.
Parameters:
name - the name of the customer to lookup
Returns:
a new or existing Customer associated with this Company

lookupOrCreateEmployee

public Employee lookupOrCreateEmployee(java.lang.String name)
Lookup an Employee and return it or return a new one if not found.
Parameters:
name - the name of the employee to lookup
Returns:
a new or existing Employee associated with this Company

lookupOrCreateSoftware

public Software lookupOrCreateSoftware(java.lang.String name)
Lookup a Software product and return it or return a new one if not found.
Parameters:
name - the name of the software product to lookup
Returns:
a new or existing Software product associated with this Company

getSoftware

public Software getSoftware(java.lang.String name)
Returns the software product of the given name.
Parameters:
name - the name of the software product to lookup
Returns:
the requested software product or null of not found

CSC407/ECE450 Assignment 1b Sample Solution