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.


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

Results 1 to 3 of 3

Thread: Subclass/Interface problem

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Thanked 0 Times in 0 Posts

    Default Subclass/Interface problem

    Hi there im having a bit of a problem, I have a House class which contains an arraylist of rooms(Room class). There is also a Property Menu class which asks the user to choose between a range of options .ie add a house. Eventually the user will be asked is the house for sale when adding a house.

    The part of the task I am having trouble with is this:

    Create a subclass of House called HouseForSale. Houses for sale have a guide price variable. Implement a zero-argument constructor for creating saleable houses interactively. Also overload toString().

    I've created the subclass and the giude price variable. In the constructor should I put in a scanner to read in the room information then put it it an House arraylist called i.e housesell?

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Subclass/Interface problem

    What happened when you tried that?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Fort Wayne, Indiana
    Thanked 31 Times in 31 Posts

    Default Re: Subclass/Interface problem

    Scanner should not be in the constructor of an object. Your object is to hold information. You should get that information prior to creating the object then just pass the value into the object.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

Similar Threads

  1. Interface and Extends problem
    By DannyGT in forum Object Oriented Programming
    Replies: 1
    Last Post: September 1st, 2011, 01:01 PM
  2. Problem with subclass and superclass methods
    By Farmer in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 15th, 2011, 08:43 PM
  3. problem with interface
    By buddy101 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 25th, 2011, 07:47 AM
  4. Interface problem please help!!
    By joff1403 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 6th, 2010, 11:09 AM
  5. Problem while implementing a basic user interface menu
    By Rastabot in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 3rd, 2009, 04:38 PM