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

2014/10/28

'(' expected?

Fuzzion Fuzzion

2014/10/28

#
I really don't know what is wrong, any help? public class watershipgameworlod extends World { /** * Constructor for objects of class watershipgameworlod. * */ public watershipgameworlod() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); addObject (new ship(), 300, 200); addObject (new Submarine(), 100, 50); addObject(new crate(), 400, 350); } private void prepare { //add the ship Ship ship = new ship(); addObject(ship, 124, 260); //ask the user how many Submarines they want to leave int Submarine = 0; //set up a local variable to store how many Submarines you want String temp; //you need this as JOptionPane can only get string values do{ //make sure they can only have up to 5 Submarines temp = JOptionPane.showInputDialog(null,"How many lobsters do you want? maximum 5"); if (isNumber(temp)) { lobsters = Integer.parseInt(temp); if (Submarines < 1 || Submarines > 5) { JOptionPane.showMessageDialog(null,"Error:between 1 and 5 only"); }//end if } else{ }//end if }while (Submarines <1 || Submarines > 5); //add that number of Submarines for (int i = 0;i < Submarines; i++){ addObject(new Submarines(), Greenfoot.getRandomNumber(530), Greenfoot.getRandomNumber(500)); } //add 10 crate for (int i = 0;i < 10; i++){ addObject(new crate(), Greenfoot.getRandomNumber(530), Greenfoot.getRandomNumber(500)); } } //end of prepare private boolean isNumber(String s) { try { Integer.parseInt(s); return true; }catch (NumberFormatException ex) { return false; } } }
davmac davmac

2014/10/28

#
When you post here there is a link that says "Posting code? read this!" just under the text area where you type your message - you need to read it. Please repost your code, this time using code tags appropriately.
danpost danpost

2014/10/28

#
The following line is incomplete:
private void prepare
It should be:
private void prepare()
with a set of open and close parenthesis after the name of the method.
You need to login to post a reply.