• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unsolved Programming Problem. Need Help.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic