I have a question about what part of this code means:
class Pet
{
private String name;
private int age;
public Pet(String n, int a)
{
_______________________________________
_______________________________________
}
public String getName()
{
return name;
}
public int getAge()
{
return age;
}
public String toString()
{
return ____________________() + " - " + _______________________();
}
}
public class ClassCompleteWorkSheet6
{
public static void main(String args[]) throws Exception
{
Scanner file = new Scanner([b]new File("worksheet6.dat"));[/b]
int runCount = file.nextInt();
for(int r=1; r<=runCount; r++){
//Construct a Pet
_______________________________ pet = new ___________________________________
//Print the Pet
}
}
}
It was given to me as a word file so it is a litle wierd. I bolded the part I'm confused about. It looks like I need a file for it but I have never seen that before so I am a bit confused.
oops well the new File("worksheet6.dat") is what I'm confused about. I think this file is suppose to print out 6 names and 6 corresponding ages for these pets. I'm pretty sure according to the output I was told I should get it should be just adding in the methods from public class Pet. But it seems to be working funny. I was thinking about adding a scanner into public class Pet but I kept getting a exception error.
*Edited: topic title renamed. Far from being a simple question
This post has been edited by pbl: 02 January 2012 - 09:01 PM

New Topic/Question
Reply



MultiQuote




|