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

2019/8/30

Help with error in my code

1
2
KIOP KIOP

2019/8/30

#
Im
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * MyCat is your own cat. Get it to do things by writing code in its act method.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyCat extends Cat
{
    /**
     * Act - do whatever the MyCat wants to do.
     */
    public void act()
    {
    /*checks if cat is bored by calling the method "isBored()" which is inherited from the cat class*/
    if(isBored())
    {
    //If it is bored,then dance
    dance();
    
}
}
}
{ 
 /*checks if cat is hungry by calling the method "isHungry()" which is inherited from the cat class*/
if(isHungry())
{
// If it is hungry, then it eats
eat();
}
}
}
{ 
 //check if cat is tried
 if(tired==true)
 {
   //If so make the cat sleep for some time
   sleep(4);
   // Then make the cat to shourt hooray
   shourtHooray();
}
} 
else
{
  //If the cats is tired it only shourts hooray
  shoutHooray();
}
}
}
{ 
 //check if cat is alone
 if(isALone())
 {
 //If so make the cat sleep for some time
 sleep(4) 
} 
else
{
 //If the cat is not alone it shouts hooray
 shoutHooray();
}
}
}
  
doing the MYCat project and have six errors where the brackets are stating class interface, or enum are expected.
danpost danpost

2019/8/30

#
You have gone bracket crazy. Remove lines 23, 24, 25, lines 32, 33, 34, lines 49, 50 and 51. The hit Control-Shift-I (as in 'I'ndent).
KIOP KIOP

2019/8/30

#
Thank you for your help will do.
KIOP KIOP

2019/8/31

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * MyCat is your own cat. Get it to do things by writing code in its act method.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyCat extends Cat
{
    /**
     * Act - do whatever the MyCat wants to do.
     */
    public void act()
    {
    /*checks if cat is bored by calling the method "isBored()" which is inherited from the cat class*/
    if(isBored())
    {
    //If it is bored,then dance
    dance();
    
}



 /*checks if cat is hungry by calling the method "isHungry()" which is inherited from the cat class*/
if(isHungry())
{
// If it is hungry, then it eats
eat();
}



 //check if cat is tried
 if(tired==true)
 {
   //If so make the cat sleep for some time
   sleep(4);
   // Then make the cat to shourt hooray
   shourtHooray();
}
}
 else
{
  //If the cats is tired it only shourts hooray
  shoutHooray();
}



 //check if cat is alone
 if(isALone());
 {
 //If so make the cat sleep for some time
 sleep(4); 
} 
else
{
 //If the cat is not alone it shouts hooray
 shoutHooray();
}
}

  
KIOP KIOP

2019/8/31

#
Now I am revceiving errors on lines 44,53,58 stating illegal start to type.
danpost danpost

2019/8/31

#
KIOP wrote...
Now I am revceiving errors on lines 44,53,58 stating illegal start to type.
Remove line 43.
KIOP KIOP

2019/8/31

#
That worked thank you. Do you do any tutoring services?
KIOP KIOP

2019/9/1

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * MyCat is your own cat. Get it to do things by writing code in its act method.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyCat extends Cat
{
    /**
     * Act - do whatever the MyCat wants to do.
     */
    public void act()
    {
    /*checks if cat is bored by calling the method "isBored()" which is inherited from the cat class*/
    if(isBored())
    {
    //If it is bored,then dance
    dance();
    
}



 /*checks if cat is hungry by calling the method "isHungry()" which is inherited from the cat class*/
if(isHungry())
{
// If it is hungry, then it eats
eat();
}



 //check if cat is tried
 if(tired==true)
 {
   //If so make the cat sleep for some time
   sleep(4);
   // Then make the cat to shourt hooray
   shourtHooray();
}

 else
{
  //If the cats is tired it only shourts hooray
  shoutHooray();
}



 //check if cat is alone
 if(isALone());
 {
 //If so make the cat sleep for some time
 sleep(4); 
}
else
{
 //If the cat is not alone it shouts hooray
 shoutHooray();
}
}
KIOP KIOP

2019/9/1

#
I Don't understand my errors on 58 and 63 I feel like I used the statements correctly.
danpost danpost

2019/9/2

#
KIOP wrote...
I Don't understand my errors on 58 and 63 I feel like I used the statements correctly.
Remove the semicolon ( ; ) at the end of line 53.
KIOP KIOP

2019/9/2

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * MyCat is your own cat. Get it to do things by writing code in its act method.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyCat extends Cat
{
    /**
     * Act - do whatever the MyCat wants to do.
     */
    public void act()
    {
    //checks if cat is bored by calling the method "isBored()" which is inherited from the cat class//
    if(isBored())
    {
    //If it is bored,then dance
    dance();
    
}



 //checks if cat is hungry by calling the method "isHungry()" which is inherited from the cat class//
if(isHungry())
{
// If it is hungry, then it eats
eat();
}



 //check if cat is tried
 if(tired==true)
 {
   //If so make the cat sleep for some time
   sleep(4);
   // Then make the cat to shourt hooray
   shourtHooray();
}

 else
{
  //If the cats is tired it only shourts hooray
  shoutHooray();
}



 //check if cat is alone
 if(isALone())
{
 //If so make the cat sleep for some time
 sleep(4); 
}
else
{
 //If the cat is not alone it shouts hooray
 shoutHooray(); 
}
}
KIOP KIOP

2019/9/2

#
I still cant seem to remove my error from line 63?
danpost danpost

2019/9/2

#
KIOP wrote...
I still cant seem to remove my error from line 63?
Close out the class by adding a closing squiggly ( } ) bracket at the end of the code.
KIOP KIOP

2019/9/2

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * MyCat is your own cat. Get it to do things by writing code in its act method.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MyCat extends Cat
{
    /**
     * Act - do whatever the MyCat wants to do.
     */
    public void act()
    {
    //checks if cat is bored by calling the method "isBored()" which is inherited from the cat class//
    if(isBored())
    {
    //If it is bored,then dance
    dance();
    
}



 //checks if cat is hungry by calling the method "isHungry()" which is inherited from the cat class//
if(isHungry())
{
// If it is hungry, then it eats
eat();
}



 //check if cat is tried
 if(tired==true)
 {
   //If so make the cat sleep for some time
   sleep(4);
   // Then make the cat to shourt hooray
   shourtHooray();
}

 else
{
  //If the cats is tired it only shourts hooray
  shoutHooray();
}



 //check if cat is alone
 if(isALone());
{
 //If so make the cat sleep for some time
 sleep(4); 
}
else
{
 //If the cat is not alone it shouts hooray
 shoutHooray(); 
}
}
}
  
KIOP KIOP

2019/9/2

#
I added a squiggly and I received another error on line 58
There are more replies on the next page.
1
2