0% found this document useful (0 votes)
28 views9 pages

COMP1112 Lab6

Uploaded by

ardagecimli70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views9 pages

COMP1112 Lab6

Uploaded by

ardagecimli70
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

COMP1112.

Lab
Spring 2024
Week #7 – Lab 6
Association Examples (Uses-Has relations)
Zoo System
• There can be many zoos in the system.
• A zoo can have one or more animals. One
animal can only belong to one zoo.
• A zoo also has its own employees. It can have
one or more employees. An employee can only
work for one zoo.
Please create the relationships between classes
and decide the type of relationships. Specify
multiplicities too.
Class Diagram only with relations
Animal
• Animal id : identifies each animal (Should be unique)
• Breed : each animal have its own breed in string
• Age: age of the animal in int
• Constructor : breed and age are taken
• Getter(s)/setter(s)
• Pair(): takes another animal object. Returns new animal with same
breed and 0 years old. Two animal can only pair if their breed are
the same and they are older then 2 years old.
• isSameBreed(): takes another animal. Returns true if breeds of
animals are the same. Otherwise, returns false.
• toString():returns the attributes of animal object
Employee
• eID: stars from 1000 and should be unique for each employee
• eName: employee name
• dailyTask: number of dailytask of employee. Will be set by
Zoo
• Salary:salary of the employee
• Constructor: name and salary are set in constructor
• Getter(s)/setter(s)
• feedAnimal():decreases dailytask by 1 if dailytask is not 0
• cleanZoo():decreases dailytask by 1 if dailytask is not 0
• toString():returns attributes of employee object.
Zoo
• Name:name of the zoo
• Location: location of the zoo
• visitorLimit: number of visitors that can be accepted in zoo
• numberOfVisitor: number of current visitors
• isOpen: Boolean variable to show if zoo is open or close.
• dailyTaskNumber: number of tasks of the zoo for employees.
• Constructor: name, location and visitorLimit are set in constructor
• Getter(s)/setter(s)
• addAnimal(): takes animal object into animal list of zoo
• removeAnimal():takes animal object and removes from the animal list of zoo
• hireEmployee():takes employee object and adds into employee list of zoo
• dischargeEmployee():takes employee object and removes from the employee
list of zoo
• checkInallEmployees():sets dailyTask of each employee according to the value
Zoo-continue
• calculateTotalSalaries():returns total salary calculated from from all
employees' salaries of the zoo
• moveAnimal():takes one other zoo object and one animal object.
Animal is moved from this object’s animal list to another zoo
object’s animal list.
• acceptVisitor():takes visitor number and increases the
numberOfvisitor of zoo. Zoo should be opened first. Visitors can not
exceed visitor limit.
• removeVisitor():takes visitor number and decreases the
numberOfvisitor of zoo. Zoo should be opened first. There should be
enough number of visitors to remove
• openZoo(): opens the zoo. Should be closed to open the zoo.
• closeZoo(): closes the zoo. Should be opened to close the zoo
TestClass
• There should be zooList which holds the zoos.
• There should be currentZoo because for some of the functions we need specific zoo object.
• Login():sets currentZoo by taking the name of the zoo
• Logout():sets currentZoo to null.
• addZoo():adding for new zoo object to list
• removeZoo():removing existed zoo from the list
• addEmployee():adds new employee to currentZoo’s employee list
• removeEmployee():removes existed employee from currentZoo’s employee list by the
given employee id
• addAnimal():inserts new animal to the animal list of currentZoo
• removeAnimal():deletes the animal object from animal list of currentZoo by the given
animal id
• transferAnimal():moves the animal whose id is given from one zoo to another zoo. For
zoos, names are given by user.
• acceptVisitor():taken number of visitors can be added by calling the acceptVisitor function
of currentZoo
• removeVisitor(): taken number of visitors can be removed from currentZoo’s
numberOfvisitors attribute. removeVisitors function of currentZoo can be called to remove.

You might also like