File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unsolved Programming Problem. Need Help.

 
mama mia
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic