Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    Sizzlewump's Avatar
    Sizzlewump is offline Member
    Join Date
    Oct 2010
    Location
    MI, USA
    Posts
    12
    Rep Power
    0

    Default

    I just realized that the driver class TestSmallRoom only passes one argument to a SmallRoom object: the roomNumber variable. I have changed my constructor to:

    Java Code:
    // constructor
    	public SmallRoom( String roomNumber )
    	{
    	   roomNumber = null; // I was trying to initialize some variables here..
    		p = null;
    	}
    and now my error log looks like this:

    TestSmallRoom.java:26: enter(java.lang.String) in SmallRoom cannot be applied to (Tutor)
    room1.enter(alan);
    ^
    TestSmallRoom.java:29: enter(java.lang.String) in SmallRoom cannot be applied to (Student)
    room2.enter(prakash);
    ^
    TestSmallRoom.java:35: enter(java.lang.String) in SmallRoom cannot be applied to (Student)
    room1.enter(bill); // rejected since already occupied
    ^
    TestSmallRoom.java:46: leave(java.lang.String) in SmallRoom cannot be applied to ()
    p = room2.leave();
    ^
    TestSmallRoom.java:52: enter(java.lang.String) in SmallRoom cannot be applied to (Student)
    room3.enter(bill);
    ^
    TestSmallRoom.java:54: leave(java.lang.String) in SmallRoom cannot be applied to ()
    room4.enter(room3.leave()); // Bill moves from room3 to room4
    ^
    6 errors

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default

    All your errors appear to be mismatched types. The compiler requires that you use the correct type as parameter to a method.
    Check all the method definitions and only pass a variable of the type they require as a parameter when you call the method.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 8
    Last Post: 04-14-2010, 05:49 AM
  2. Replies: 7
    Last Post: 05-06-2009, 12:42 PM
  3. Replies: 8
    Last Post: 03-21-2009, 09:34 AM
  4. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 12:25 AM
  5. Replies: 0
    Last Post: 05-13-2008, 06:16 AM

Posting Permissions

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