-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFood.java
More file actions
40 lines (37 loc) · 1.17 KB
/
Food.java
File metadata and controls
40 lines (37 loc) · 1.17 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* A general class that shares a few methods and variables that all food
* possess.
*
* @author Isaac Chan
* @version January 28, 2022
*/
public class Food extends Actor
{
//food objects start uncut
boolean isCut = false;
public void act()
{
chopFood();
}
public void chopFood() //sets the food as either cut or not
{
if(isTouching(CuttingBoard.class)){
//gets a cutting board thatis touching the food object
CuttingBoard cuttingBoard = getIntersectingObjects(CuttingBoard.class).get(0);
//determines whether the food is cut or not
isCut = cuttingBoard.isCuttingFood(isCut);
}
}
public boolean choppingOnCuttingBoard(Counter counter) //checks whether the food is being chopped or not
{
if(isTouching(CuttingBoard.class) && counter.getCurrVal() < 120){ //of the food object is still being cut
return true;
}
return false;
}
public boolean hasBeenCut() //returns whether the object is cut or not
{
return isCut;
}
}