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

Thread: help with project

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help with project

    first off im taking a java class in school and i was doing fine but its starting to get harder with inheritance and polymorphism < still dont know what that is

    when do i know to use private or protected modifier, i always do private but now i learned of protected

    the project i am doing is kind of big but ill start with my specific problem
    "Write a new class called Upgrade which inherits from Standard with the following characteristics:"
    Name
    UpgradeRoom
    Return Type
    Parameter
    number – integer
    stay – integer
    Pre-condition
    none
    Post-condition
    constructs an object of class UpgradeRoom with
    roomNumber = number;
    roomRate = 170.0;
    lengthOfStay = stay;
    mimimumStay = 3

    ^ this is given to tell us how to make a method, he posted the answer as
        public UpgradeRoom(int number, int stay)
        {
            super(number, stay);
            rate = 170.0;
            minimumStay = 3;
        }
    my question is why does it not say roomRate = 170 its instead rate ...
    also explain the super(number, stay) please i am confused. I am under the impression that super means your using the same number and stay as the main class or something? dont know..

    the class UpgradeRoom has only 1 new variable which is
    "protected int minimumStay;"

    i dont get why its protected!
    Last edited by helloworld922; May 7th, 2010 at 10:26 AM.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: help with project

    Quote Originally Posted by pairenoid View Post
    ... its starting to get harder with inheritance and polymorphism < still dont know what that is
    Google for it, there are lots of explanations.

    my question is why does it not say roomRate = 170 its instead rate ...
    Common sense would suggest he made a typo.

    also explain the super(number, stay) please i am confused. I am under the impression that super means your using the same number and stay as the main class or something? dont know..
    'super' refers to the superclass. Calling super(number, stay) calls the superclass constructor so that 'number' and 'stay' are handled by the existing superclass code.

    the class UpgradeRoom has only 1 new variable which is "protected int minimumStay;"
    i dont get why its protected!
    Using 'protected' makes it visible to subclasses and other classes in the same package. Normally you would use it when you expect a subclass to need access to it. Using it here implies that you may want to subclass UpgradeRoom at some point and set a different minimumStay value. Alternatively, it may be another mistake by your tutor, or he may have put it in there deliberately to make you think - why not ask him?

Similar Threads

  1. Project - Please Help
    By toxikbuni in forum Java Theory & Questions
    Replies: 0
    Last Post: April 20th, 2010, 09:58 AM
  2. Can anyone help me on my project?
    By alesana514 in forum Paid Java Projects
    Replies: 1
    Last Post: December 16th, 2009, 09:24 AM
  3. Need Help With Project
    By jstew132 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2009, 07:15 PM
  4. Need a project
    By helloworld922 in forum Project Collaboration
    Replies: 6
    Last Post: July 31st, 2009, 08:30 AM
  5. Adventure ride project
    By Ciwan in forum Java Theory & Questions
    Replies: 12
    Last Post: February 15th, 2009, 12:08 PM