-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimalFactory.java
45 lines (34 loc) · 1016 Bytes
/
AnimalFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* animal factory class return the specific object by getting message (string)
* @author Adir Zoari 203002753
* @author Idan Levi 305562431
*/
import java.awt.Color;
public class AnimalFactory implements AbstractSeaFactory {
private int size,horSpeed,verSpeed,foodFreq;
private Color col;
private AquaPanel panel;
public AnimalFactory(AquaPanel panel,int size,int horSpeed,int verSpeed,Color col,int foodFreq)
{
this.panel=panel;
this.size=size;
this.horSpeed=horSpeed;
this.verSpeed=verSpeed;
this.col=col;
this.foodFreq=foodFreq;
}
/**
* interface with one method to create sea creature :swimmable\immobile object
* @return the object by the message
*
*/
@Override
public SeaCreature produceSeaCreature(String type){
if(type.equalsIgnoreCase("Fish")){
return new Fish(panel,size,horSpeed,verSpeed,col,foodFreq);
}
else if(type.equalsIgnoreCase("Jellyfish"))
return new Jellyfish(panel,size,horSpeed,verSpeed,col,foodFreq);
return null;
}
}