Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Userinfo class help

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Userinfo class help

    Hello all, i am having trouble with this assignment where i have to make a class called userinfo that has fields (name,phone number,address, and idNumber). i must define the class using setters,getters a constructor and a toString method. i have to make the constructor generate the idnumber by defining a static variable named lastidNumberUsed somehow. I do not understand this, my professor is not very helpful and there are no java tutors in my area. i would appreciate any kind of help or feed back. Thanks


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Userinfo class help

    What have you done?

    I am more than weilling to help but I will not do it for you. If you ask a specific question about a specific problem then I can provide a specific answer. Many times people say "I don't know where to start". If that is true then you should not be doing the course. Writing a class with the correct name that does not is a start. You then go from there using your instructions as a guide. By that I mean it tells you exactly what instance variables you need. All you have to do is determine what type they should be.

    In brief, make a start. When you get stuck post your code and any error messages and ask specific questions.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Userinfo class help

    Well alright, so far i have.
    import java.util.Scanner;

    public class userinfo
    {

    public int name;
    public int phone;
    public int address;
    public int idNumber;

    public userinfo() {
    }
    public void set name(int newValue) {
    name = newValue;
    }

    public void set phone (int newValue) {
    phone = newValue;
    }
    public void set address (int newValue) {
    address = newValue;
    }


    I do not know what to do from here, or how to approach making the static variable that produces my random number.

  4. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Userinfo class help

    Well alright, so far i have.
    import java.util.Scanner;

    public class userinfo
    {

    public int name;
    public int phone;
    public int address;
    public int idNumber;

    public userinfo() {
    }
    public void set name(int newValue) {
    name = newValue;
    }

    public void set phone (int newValue) {
    phone = newValue;
    }
    public void set address (int newValue) {
    address = newValue;
    }


    I do not know what to do from here, or how to approach making the static variable that produces my random number.

  5. #5
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Userinfo class help

    Quote Originally Posted by sunce69 View Post

    I do not know what to do from here, or how to approach making the static variable that produces my random number.
    - Declare a static variable as private member of the class.
    - Increase the static variable's value by 1 and assign it to the ID variable.

    java exception
    Last edited by hns1984; January 11th, 2012 at 05:58 PM.

Similar Threads

  1. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM
  2. In a class create an array list of elements of another class, help!
    By LadyBelka in forum Collections and Generics
    Replies: 3
    Last Post: May 4th, 2011, 05:00 PM
  3. Replies: 3
    Last Post: April 13th, 2011, 03:30 PM
  4. Help requested - testing a class with a tester class, no methods allowed.
    By miketeezie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2011, 09:40 PM
  5. Replies: 0
    Last Post: April 11th, 2010, 08:56 AM