Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29
  1. #21
    manda147 is offline Member
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    there's addCredits and removeCredits.... but i still don't know how to incorporate them

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Question: Did you write the Student object? Or was it given to you? (I know the answer to this)
    If given to you, by whom? Your teacher?

    To answer your question, you incorporate them the same as I showed you in the MyFubar example, only my example used a setXXX rather than addXXX example.

    Also, lets simplify your test class. Again, get rid of the Scanner and just start very simply like so:
    Java Code:
    public class StudentDriver
    {
      public static void main(String[] args)
      {
        Student myStudent = new Student("John", 1234, new UndergradFeeCalculator());
        // how would you add 3 credits to the myStudent object?
        
      }
    }
    Again, what one line of code would you call here to add 3 credit hours to the myStudent object?
    Last edited by Fubarable; 11-17-2008 at 03:20 AM.

  3. #23
    manda147 is offline Member
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    there's the addCredits and removeCredits .......... but i don't know how to incorporate that ....

  4. #24
    manda147 is offline Member
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    the student object was given in the assignment

  5. #25
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by manda147 View Post
    there's the addCredits and removeCredits .......... but i don't know how to incorporate that ....
    Take my code above, and try, something, anything, just try to use one of these methods above. Which do you think you should use? hint, you're adding credits here.

    edit: as an aside, do you see how my Student constructor call is different from yours? Yours won't compile as it doesn't pass parameters to the object.
    Last edited by Fubarable; 11-17-2008 at 03:27 AM.

  6. #26
    manda147 is offline Member
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    So i've got:

    Java Code:
    public class TestStudent 
    {
    
    
    public static void main(String[] args)
      {
           
        Student myStudent = new Student("name", 1234, new UndergradFeeCalculator());
       
        System.out.println("Your housing fee is $"+myStudent.getHousingFees());  
       
        myStudent.addCredits(5);
        myStudent.removeCredits(0);
        System.out.println("Your tuition is $"+myStudent.getTuitionFees());
        
      }
    }

  7. #27
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    OK, that looks a lot better. Do you understand why this is starting to work?

    Now question: what purpose dose calling removeCredits(0) have?

  8. #28
    manda147 is offline Member
    Join Date
    Nov 2008
    Posts
    16
    Rep Power
    0

    Default

    in my situation it doesn't have a purpose because it's not used since we're only adding credits. but if someone were to remove credits it would be useful, right?

    thanks so much for your help!! =)

  9. #29
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Implementing Interface
    By mew in forum New To Java
    Replies: 4
    Last Post: 02-16-2010, 03:33 PM
  2. Implementing an interface
    By bugger in forum Advanced Java
    Replies: 1
    Last Post: 01-09-2008, 01:35 PM
  3. Implementing Serializable interface
    By javaplus in forum Advanced Java
    Replies: 4
    Last Post: 12-18-2007, 12:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •