-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPetRock.java
More file actions
55 lines (49 loc) · 1.54 KB
/
Copy pathPetRock.java
File metadata and controls
55 lines (49 loc) · 1.54 KB
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
public class PetRock extends Animal implements Flying,Swimming
{
private int weight;
public PetRock(int weight)
{
super("Pet Rock","This is a rock");
this.weight = weight;
}
public PetRock(String name,String des,int weight)
{
super(name,des);
this.weight = weight;
}
@Override
public String play(){
return "The rock stares with intent";
}
@Override
public String makeNoise(){
if(weight<0)
{return "*whoooossssh*, Why is the rock flying?";}
else if(50>weight && weight>=0)
{return "*tap*, ops it fell";}
else if(150>weight && weight>=50)
{return "*crash*, ops it fell";}
else if(weight>=1000 && weight>=150)
{return "*BOOM*, whoa it fell and crack the floor";}
else
return "*Ka Boo*, OMG THE ROCK IS DESTROYING THE EARTH";
}
@Override
public String eat(){
return "Pet rock cannot eat";
}
public String fly(){
if(weight<0)
{return "Pet rock was releaced and it flew in to the atmosphere";}
if(weight>=1000)
{return "Pet rock will not move";}
return "Pet rock is hurdled " + Math.round((weight+1) / 3.8) + " ft into the sky";
}
public String swim(){
if(weight<0)
{return "Pet Rock rises from the water and aims for the sky";}
if(weight>=1000)
{return "Pet rock sinks at an alarming rate";}
return "Pet rock is sinks " + Math.round((weight+1) * 0.4) + " ft per second";
}
}