-
Notifications
You must be signed in to change notification settings - Fork 0
/
Memento.java
94 lines (86 loc) · 2.46 KB
/
Memento.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Memento class is class for save the current details of the object with his directly place
* @author Adir Zoari 203002753
* @author Idan Levi 305562431
*/
import java.awt.Color;
public class Memento {
private int idObj,size,x_front,y_front,horSpeed,verSpeed;
private double x_dir,y_dir;
private Color col;
private String ColorAnimal,animalType;
private Swimmable swimObj=null;
public Memento(Swimmable swimObj)
{
this.swimObj=swimObj;
this.idObj=swimObj.getID();
this.col=swimObj.getColorAnimal();
this.size=swimObj.getSize();
this.x_front=swimObj.getXfront();
this.y_front=swimObj.getYfront();
this.horSpeed=swimObj.getHorSpeed();
this.verSpeed=swimObj.getHorSpeed();
this.animalType=swimObj.getAnimalName();
this.x_dir=swimObj.getX_dir();
this.y_dir=swimObj.getX_dir();
}
public Memento(Immobile immObj){
this.idObj=immObj.getID();
this.col=immObj.getColorPlanet();
this.size=immObj.getSize();
this.x_front=immObj.getXfront();
this.y_front=immObj.getYfront();
this.animalType=immObj.getPlanetName();
}
/*
public Memento(int idObj,Color col,int size,int x_front,int y_front,int horSpeed,int verSpeed,String animalType,double x_dir,double y_dir)
{
this.idObj=idObj;
this.col=col;
this.size=size;
this.x_front=x_front;
this.y_front=y_front;
this.horSpeed=horSpeed;
this.verSpeed=verSpeed;
this.animalType=animalType;
this.x_dir=x_dir;
this.y_dir=y_dir;
}
public Memento(int idObj,Color col,int size,int x_front,int y_front,String animalType)
{
this.idObj=idObj;
this.col=col;
this.size=size;
this.x_front=x_front;
this.y_front=y_front;
this.animalType=animalType;
}
*/
public Color getCol(){return col;}
public String getColor() {
//String colorAnimal=null;
if (col== Color.BLUE)
ColorAnimal="blue";
if (col==Color.RED)
ColorAnimal="red";
if (col== Color.GREEN)
ColorAnimal="green";
if (col== Color.BLACK)
ColorAnimal="black";
if (col==Color.yellow)
ColorAnimal="yellow";
if(col==Color.pink)
ColorAnimal="pink";
return ColorAnimal;
}
public int getID(){return idObj;}
public int getSize(){return size;}
public int getXfront(){return x_front;}
public int getYfront(){return y_front;}
public int getHorSpeed(){return horSpeed;}
public int getVerSpeed(){return verSpeed;}
public String getAnimalName(){return animalType;}
public double getX_dir(){return x_dir;}
public double getY_dir(){return y_dir;}
public String getHungerStatus(){return swimObj.getHungerState();}
}