aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Unsolved Programming Problem. Need Help. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Unsolved Programming Problem. Need Help." Watch "Unsolved Programming Problem. Need Help." New topic
Author

Unsolved Programming Problem. Need Help.

mama mia
Greenhorn

Joined: Jan 29, 2004
Posts: 1
Hello, All.
I'm working with inheritance. And, I'm having problem establishing an array that will hold all the entries I need. I don't know if I need to create a new object to hold the various types within the array. Or, create a different array for each type (variable). The more I work on the problem, the more confused I become. Can anyone please put me on the right path? I need to know if I am completely over doing this assignment that follows (this just the driver program):
import java.lang.reflect.Array;
import java.util.Arrays;
import java.io.*;
import java.util.*;
public class PetRecordDemo
{
public static int ans;
public static int index;
public static Cat[] record = new Cat[3];//Array object to hold cat information
public static void main(String[] args)
{
PetRecord pet = new PetRecord();
Cat usersPet = new Cat();
System.out.println("This program collects basic pet information for Cats.\n");
System.out.println("My records on your Cat are inaccurate.");
System.out.println("Here is what they currently say:\n");
usersPet.writeOutput();
//***************************************************************************
System.out.println("\nPlease enter the information for three Cats.");
for (index = 0; index < 3; index++)
{
record[index] = new Cat();
System.out.println("Please enter the correct name for cat number " + (index + 1) + ":");
String correctName = SavitchIn.readLine();
System.out.println("\nPlease enter the correct cat age:");
int correctAge = SavitchIn.readLineInt();
System.out.println("\nPlease enter the correct cat weight:");
double correctWeight = SavitchIn.readLineDouble();
System.out.println("\nPlease enter the correct cat breed: ");
String correctBreed = SavitchIn.readLine();
System.out.println("\nPlease enter whether the cat has CLAWS or NO CLAWS.");
System.out.println("Enter 1 for CLAWS, 2 for NO CLAWS.");
ans = SavitchIn.readLineInt();
System.out.println("\n\n");
usersPet.set(correctName, correctAge, correctWeight, correctBreed, usersPet.getClaw());
}
//System.out.println(record[0]);
//System.out.println(record[1]);
//System.out.println(record[2]);
//record[1].writeOutput();
//for(index = 0; index < 3; index++)
//{
//if(pet.getAge() > 3)
//{
//record[index].writeOutput();
//}//end of for statement
//System.out.println(usersPet.toString());
System.out.println("\nMy updated records now say:");
usersPet.writeOutput();
System.out.println(" ");
}
}
Thank you.
Helpless.
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
I probably speak for most when I say you're being too non-specific, basically wanting someone to review your code and design for you (for free as well). Probably ain't gonna happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unsolved Programming Problem. Need Help.
 
Similar Threads
Halloween Party
Input/Output PetRecord
Party Program
Array without ints
Grading Program--Need help, please!!!