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 6 of 6

Thread: Help with creating classes and sub classes

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

    Exclamation Help with creating classes and sub classes

    Hello I need help with a java problem,i cant seem to get it.The problem is as follows.
    Consider a class RatingScore its attributes are a
    attributes
    a description of what is being rated ,the max rating and the user rating.
    Methods
    get userrating, get max rating and a write a description based on the maxrating and userrating.
    THis is the first part of the problem then it goes on to say consider another class that will judge a project its attributes are
    attributes
    projectname,idofproject,nameofperson,thoughtscore
    methods
    return rating and maximum rating
    I know I have to use the class RatingScore with the project class but I do not know how
    here is my code so far
    This is for RatingScore

    public class RatingScore
    {
    private int UserRating;
    private int maxRating;
    private String description;

    public void setUserRating(int newUserRating)
    {
    UserRating = newUserRating;
    }
    public void setmaxRating(int newmaxRating)
    {
    maxRating = newmaxRating;
    }

    public int getUserRating()
    {
    return UserRating;
    }

    public int getmaxRating()
    {
    return maxRating;

    }
    public void description()
    {
    System.out.println("the max rating for this project was" + maxRating + "the score you got was" +UserRating);
    }



    }


    THen I need to work it into the other class and this is where I need help with connecting the ideas

    public class ScienceFairProject

    {

    RatingScore ScienceFairProject = new RatingScore();

    private RatingScore thought;



    public void setthought(RatingScore newthought)
    {
    thought=newthought;

    }




    }


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

    Default Re: Help with creating classes and sub classes

    To avoid confusion you should avoid giving variables/methods/classes the same name.
    Why have you declared 2 RatingScore variables in the ScienceFairProject?
    To get better help you need to ask a specific question. "I don't know how" is not a question nor is it specific.
    Improving the world one idiot at a time!

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

    Default Re: Help with creating classes and sub classes

    Do you mean when I set
    RatingScore ScienceFairProject = new RatingScore();

    private RatingScore thought;
    I am supposed to take what they give me in the thought which is located in the ScienceFairProject class and somehow make it display description from the RatingScore class

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

    Default Re: Help with creating classes and sub classes

    So you have to create ONE RatingScore object. I repeat my question why do you have TWO variables?
    Improving the world one idiot at a time!

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

    Default Re: Help with creating classes and sub classes

    Im not seeing where I have two variables could you post the code

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

    Default Re: Help with creating classes and sub classes

    What do you mean "post the code"? It's your code not mine.
    Improving the world one idiot at a time!

Similar Threads

  1. Classes
    By Philani in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 19th, 2013, 05:59 PM
  2. CREATING NESTED CLASSES
    By Benito NuGen in forum Object Oriented Programming
    Replies: 5
    Last Post: April 18th, 2013, 12:58 PM
  3. Replies: 6
    Last Post: October 31st, 2012, 06:16 AM
  4. Creating classes with generic objects
    By rbt in forum Collections and Generics
    Replies: 2
    Last Post: April 23rd, 2012, 08:08 PM
  5. Question about creating and using classes.
    By iDizzle in forum Object Oriented Programming
    Replies: 20
    Last Post: April 1st, 2012, 03:14 PM