Hello! I am programming a click-based diner game in which the player clicks the customer and their associated order tickets pop up. Based on if the player clicks the right ticket, it will award them points and remove the objects from the world. Everything was fine until I realized that when running the game, the tickets show up randomly and not with their specific customer.
For instance, I programmed one customer to order a burger but when you run the game they instead order a pizza.
Any help would be appreciated, thank you.
This is my code for one of the customers and their order slips:
import greenfoot.*;
public class RedCustomer extends Customer
{
public void act()
{
spawnOrderSlip();
}
public void spawnOrderSlip() {
if (Greenfoot.mousePressed(this) == true) { // player presses on customer
getWorld().addObject(new Burger(), 180,200); //spawns right order ticket
getWorld().addObject(new BurgerWrong(), 500, 200); //spawns wrong order ticket
}
}
}
import greenfoot.*;
public class Burger extends OrderSlip1
{
public void act()
{
correctAnswer();
}
public void correctAnswer()
{
if (Greenfoot.mousePressed(this) == true) {
getWorld().removeObjects(getWorld().getObjects(OrderSlip2.class));
getWorld().removeObject(this);
Diner.tips+=100;
Diner.customer_visits++;
}
}
}
import greenfoot.*;
public class BurgerWrong extends OrderSlip2
{
MonkeyDiner diner;
public void act()
{
wrongAnswer();
}
public void wrongAnswer() {
if (Greenfoot.mousePressed(this) == true) {
//still deciding if I want to have it do nothing or display text
}
}
}

