This site requires JavaScript, please enable it in your browser!
Greenfoot back
Luisam21
Luisam21 wrote ...

2023/6/28

Help needed car simulator

Luisam21 Luisam21

2023/6/28

#
Hello, can someone help me? I am programming a simple car simulator and want the user to put in the destination and depending on where the destination is I want a object (little flag) to appear on The map but I doesn’t appear,’. ( Destination is the class of the flag) My code in stride: Fields: private String end =„“ Constructor: public Map() super (1200, 800, 1) end = Greenfoot. ask( "What is your Destination?" ) if (end == "Hospital" ) var Destination destination = new Destination ( ) addObject (destination, 599, 465)
danpost danpost

2023/6/28

#
Luisam21 wrote...
Hello, can someone help me? I am programming a simple car simulator and want the user to put in the destination and depending on where the destination is I want a object (little flag) to appear on The map but I doesn’t appear,’. ( Destination is the class of the flag) << Code Omitted >>
The input value might be the same as the literal string given; however, it is not the same object (two different strings containing similar character string sets). To compare the two, use:
if ("Hospital".equals(end))
Luisam21 Luisam21

2023/6/29

#
danpost wrote...
Luisam21 wrote...
Hello, can someone help me? I am programming a simple car simulator and want the user to put in the destination and depending on where the destination is I want a object (little flag) to appear on The map but I doesn’t appear,’. ( Destination is the class of the flag) << Code Omitted >>
The input value might be the same as the literal string given; however, it is not the same object (two different strings containing similar character string sets). To compare the two, use:
if ("Hospital".equals(end))
Thank you so much! It works now :)
You need to login to post a reply.