-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlate.java
More file actions
47 lines (44 loc) · 1.62 KB
/
Plate.java
File metadata and controls
47 lines (44 loc) · 1.62 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* An object that holds the soup and allows it to be served
*
* @author Isaac Chan
* @version January 28, 2022
*/
public class Plate extends Food
{
//variables to determine what type of soup it is
private boolean isOnionSoup = false;
private boolean isTomatoSoup = false;
public void act()
{
takeSoup();
}
public void takeSoup() //when grabbing soup from the pot
{
//finds a cooking pot object that this is interacting with
Actor findCookingPot = getOneIntersectingObject(CookingPot.class);
CookingPot foundCookingPot = (CookingPot)findCookingPot;
if(isTouching(CookingPot.class)){ //if this is touching a cooking pot
if(foundCookingPot.getSoupInPot().equals("onion")){ //if the pot has onion soup
//set the image as an onion soup
GreenfootImage onionSoup = new GreenfootImage ("OnionPlate.png");
setImage(onionSoup);
isOnionSoup = true;
} else if(foundCookingPot.getSoupInPot().equals("tomato")){ //if the pot has tomato soup
//set the image as a tomato soup
GreenfootImage tomatoSoup = new GreenfootImage ("TomatoPlate.png");
setImage(tomatoSoup);
isTomatoSoup = true;
}
}
}
public boolean getOnionSoup() //checks if the plate is an onion soup
{
return isOnionSoup;
}
public boolean getTomatoSoup() //checks if the plate is a tomato soup
{
return isTomatoSoup;
}
}