Main Method
I would like to know how to rewrite this main method so that it can read 3 or more inputs. It only reads one input at the moment.
import java.util.*;
public class Java
{
public static void main(String[] args)
{
Cat myPet1 = new Cat ("bob", 3, 7.623, "burmese", true );
Cat myPet2 = new Cat ("kool", 2, 4.333, "house", true );
myPet1 = myPet2;
for (int i = 0; i < 2; i++)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter name of cat:");
String correctName = keyboard.nextLine( );
System.out.println("Enter age of cat:");
int correctAge = keyboard.nextInt( );
System.out.println("Enter weight of cat:");
double correctWeight = keyboard.nextDouble( );
System.out.println("Enter the breed of cat:");
String correctBreed = keyboard.next( );
System.out.println("Does the cat have claws? True or False?:");
boolean haveclaws = keyboard.nextBoolean( );
System.out.println("\n");
myPet1.set(correctName, correctAge, correctWeight);
myPet1.set(haveclaws);
myPet1.set(correctBreed);
}
;
if ((myPet1.getAge() > 3 ) && ( myPet1.getDeClawed()))
{
System.out.println("Cats over 3 with claws are:");
System.out.println("Name: " + myPet1.getName() );
System.out.println("Age: " + myPet1.getAge() +" years old");
}
}
}
[1458 byte] By [
zebra40a] at [2007-11-27 9:20:24]

The advice has been great thus far, but I am getting all sorts of errors.
I have completed these steps:
created the method in my derived class.
declared the var in my main method , created the loop as suggested and now I am getting these error messages even after I call this method
public String makeNewCat()
{
return makeNewCat;
}
I now get this error:
cannot find symbol
symbol : method makeNewCat()
location: class week3_4Prog
myCatArray = makeNewCat();
^
> created the method in my derived class.
The suggestion wasn't to add any methods to any other class. I'm not sure what you mean by "my derived class", but makeNew Cat() should go in the class you posted.
You currently have this method returning a String. Why? As was suggested above this method should create and return a Cat.
As far as the body of this method goes, it's not clear what "return makeNewCat;" is supposed to do. Again as suggested a couple of times above, the method should simply repeat what you were doing in the for loop.
Perhaps you should post the full code along with the error messages. Use the code tags (Click on "Formatting tips" near the text area where you enter your post). But also comment the code or otherwise explain what you intend each method to do.
This might help:import java.util.*;
public class Java
{
public static void main(String[] args)
{
// (1) Have a Cat array of 3 Cats
/* Declare the array here */
// (2) Have a for loop that contains a method to allow you to
//update your Cat array:
for (int i = 0; i < myCatArray.length; i++)
{
myCatArray[i] = makeNewCat();
}
System.out.println("Cats over 3 with claws are:");
for (int i = 0; i < myCatArray.length; i++)
{
Cat toTest = myCatArray[i];
if(toTest.getAge() > 3 ) && toTest.getDeClawed())
{
System.out.println("Name: " + toTest.getName() );
System.out.println("Age: " + toTest.getAge() +" years old");
}
}
}
// (3) Create a method (here called makeNewCat()) that accepts user
//input, creates a new Cat and stuffs the input into the new cat and
//returns this Cat variable.
static Cat makeNewCat()
{
/* Use code similar to what you had in the for loop to get information */
/* Use the Cat class constructor (and possibly setters) to create the Cat */
/* Return the Cat you have created */
}
}