Reputation: 2 Apprentice
- Active Members
- Active Posts:
- 95 (0.09 per day)
- 19-October 12
- Profile Views:
- Last Active:
- Jan 29 2014 03:37 PM
- Dream Kudos:
Posts I've Made
Posted 21 Oct 2013Yeah I see, sorry. What I meant was how exactly do I assign the data that the user would input into the class? I am trying to do that here:
// Ask the user for pet data. 28 System.out.println("Enter the name of your pet: "); 29 pName = keyboard.nextLine(); 30 pet.setName(pName); // here 31 32 System.out.println("Enter the type of your pet: "); 33 pType = keyboard.nextLine(); 34 pet.setType(pType); // here 35 36 System.out.println("Enter the age of your pet: "); 37 pAge = keyboard.nextInt(); // and here 38 pet.setAge(pAge);
Posted 21 Oct 2013I tried initializing it at a later point, but I don't think I was writing it correctly. I tried something like pet.PetClass(pName, pType, pAge) and just got more errors...
How does a default constructor work? Does it have the same purpose as a regular constructor?
Posted 21 Oct 2013I agree with you by naming it "Pet" rather than "PetClass" but we are required to name the files by Class and Demo so the teacher can understand the files we send to her.
I realized how to initialize the class like that before, but I need to put data in from the user from the keyboard, so if I initialized it, it would be doing the assignment wrong.
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown
4N63L-Z3R0 hasn't added any friends yet.