File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help" Watch "help" New topic


John Cu

Joined: Oct 31, 2001
Posts: 2
i want make it walk instead displaying the jump and walk at the same time.

import MoveCat;
import cs1.Keyboard;
public class Cat
public static void main (String []args)
MoveCat boringCat = new MoveCat();
System.out.println("The cat's original position is at: (0,0,0)");

int width = boringCat.getwidth();
int length = boringCat.getlength();
int height = boringCat.getheight();
System.out.println("Cat walked("+width+","+length+")"); // display the width and length the cat has walk
System.out.println("Cat jumped("+height+")"); // display the distance the cat jump
System.out.print("New position: (" +width+","+length+","+height+")"); // display the new position tof the cat
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Not sure if I understand the question properly, are you saying you want to print out just the walked info and then just the jumped info. Or is it that the cat might walk, or jump or only one or the other or both?
If it is a case of figuring out what it did, you would have to have some sort of variable in the MoveCat class or the Cat class that would say what it did then you could test those variables and respond appropriately. something like this:

I don't know if that is the right place for your variables or not, they might be better in the MoveCat class it would depend on where the Cat actually gets moved from. You'd also need to have some way to set the walked and jumped variables when the Cat did one or the other.
the only ohter way I can think of to do it wuld be to test the width, length, and height variales for any change and then determine what the Cat did and print the appropriate information.
if I didn't understand what you need to do please clarify it and let me know

Sun Certified Programmer for the Java� 2 Platform

I agree. Here's the link:
subject: help
It's not a secret anymore!