4N63L-Z3R0's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
95 (0.09 per day)
Joined:
19-October 12
Profile Views:
610
Last Active:
User is offline Jan 29 2014 03:37 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   4N63L-Z3R0 Learning. :]

Posts I've Made

  1. In Topic: error with class object

    Posted 21 Oct 2013

    Yeah 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);
    
  2. In Topic: error with class object

    Posted 21 Oct 2013

    I 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?
  3. In Topic: error with class object

    Posted 21 Oct 2013

    I 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. :/

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

4N63L-Z3R0 hasn't added any friends yet.

Comments

4N63L-Z3R0 has no profile comments yet. Why not say hello?