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

2018/7/9

Having issues with this code...can anyone help?

Shookems Shookems

2018/7/9

#
public class Cat extends Actor { public void Act() { playPiano(); } /** * Set up a method to make Cat have some awesome dance moves while playing the piano. */ private void twoPlayMoves(int howMany); /** * Walk a bit to the left. 'distance' determines how far to walk. Use small numbers (1 to 10). */ public void walkLeft(int distance) { walk(distance, -10, "cat-walk.png", "cat-walk-2.png"); } /** * Walk a bit to the right. 'distance' determines how far to walk. Use small numbers (1 to 10). */ public void walkRight(int distance) { walk(distance, 10, "cat-walk-right.png", "cat-walk-right-2.png"); } /** * Internal walk method. Walk a given distance into a given direction, using given images. */ private void walk(int distance, int direction, String img1, String img2) { for (int i=0; i<distance; i++) { setImage(img1); this.wait(4); setLocation(getX() + direction, getY()); setImage(img2); this.wait(4); setLocation(getX() + direction, getY()); } setImage("cat.png"); } /** * I want the cat to play */ public void playPiano() { this.walkRight(8); Greenfoot.playSound("snoopy.wav"); this.wait(10); setImage("spin-1.png"); this.wait(6); setImage("spin-2.png"); this.wait(6); setImage("spin-3.png"); this.wait(6); setImage("spin-3-piano.png"); this.wait(6); setImage("spin-4-piano.png"); this.wait(6); setImage("spin-5-piano.png"); this.wait(6); // Infinite loop to start off the introduction of our cool cat's entrance to the piano int i = 0; while( i <= 8) {setImage("cat-play-3-piano.png");wait(6); setImage("cat-play-4B-piano.png"); wait(6); i = i+1; Greenfoot.playSound("snoopy.wav"); } private void twoPlayMoves(howMany); { count = 1; while ( count <= howMany) {setImage("cat-play-3-piano.png");wait(6); setImage("cat-play-4B-piano.png"); wait(6); count = count + 1; } } // int n=1; // while ( n <= 8 ) // { setImage("cat-play-3-piano.png");wait(6); // setImage("cat-play-4B-piano.png");wait(6); // n=n+1; // } // setImage("cat-play-3-piano.png"); // this.wait(3); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // while (n<=10) // { setImage("cat-play-3-piano.png");wait(6); // setImage("cat-play-4B-piano.png");wait(6); // n=n+1; // } // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); // setImage("cat-play-3-piano.png"); // this.wait(6); // setImage("cat-play-4B-piano.png"); // this.wait(6); { setImage("spin-5-piano.png"); this.wait(6); setImage("spin-4-piano.png"); this.wait(6); setImage("spin-3-piano.png"); this.wait(6); setImage("spin-3.png"); this.wait(6); setImage("spin-2.png"); this.wait(6); setImage("spin-1.png"); this.wait(6); setImage("cat.png"); } } /** * Wait for a given time. */ public void wait(int time) { Greenfoot.delay(time); } }
danpost danpost

2018/7/9

#
Shookems wrote...
Having issues with this code...can anyone help? << Code Omitted >>
You have some loose codes after the comments that seem to fall outside the class code block (your class code seems to end before the commented out code).
Shookems Shookems

2018/7/9

#
thanks
You need to login to post a reply.