Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unsolved Programming Problem. Need Help.  RSS feed

mama mia
Posts: 1
  • 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.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");
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();
usersPet.set(correctName, correctAge, correctWeight, correctBreed, usersPet.getClaw());
//for(index = 0; index < 3; index++)
//if(pet.getAge() > 3)
//}//end of for statement
System.out.println("\nMy updated records now say:");
System.out.println(" ");
Thank you.
Billybob Marshall
Ranch Hand
Posts: 202
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!