SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 4th, 2008, 01:44 AM
spywx2003 spywx2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 spywx2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 38 sec
Reputation Power: 0
Homework - Using "super()"

hi, i am new at java and i want to know how can i use super for this 2 constructors

this is the parent class constructor

public Room(String building, String roomNumber, int capacity)
{

Building=building;
RoomNumber=roomNumber;
Capacity=capacity;

}

example format for Room " NSB C205 164 "

my question is how can i make a sub class so the new sub class format look like this "L|REM|214|25|Chemistry lab"

heelp pllzzz

Reply With Quote
  #2  
Old May 4th, 2008, 09:51 AM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 530 tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 8 h 15 m 14 sec
Reputation Power: 129
Send a message via ICQ to tvc3mye Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye
Super class

I don't think this has any thing to do with the constructor in the super class.

Simply invoke super() by passing in all the necessary parameters to it would do.

As for changing the format of the display, if there's a method in the class which prints out values in certain format, you simply need to override the method in your subclass. Otherwise, declare a method which prints out the values of all parameters in your desired format.
Comments on this post
spywx2003 agrees: Help a lot
__________________
When the programming world turns decent, the real world will turn upside down.

Reply With Quote
  #3  
Old May 4th, 2008, 03:16 PM
spywx2003 spywx2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 spywx2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 38 sec
Reputation Power: 0
Quote:
Originally Posted by tvc3mye
I don't think this has any thing to do with the constructor in the super class.

Simply invoke super() by passing in all the necessary parameters to it would do.

As for changing the format of the display, if there's a method in the class which prints out values in certain format, you simply need to override the method in your subclass. Otherwise, declare a method which prints out the values of all parameters in your desired format.


alright i got you so for example this how the subclass should look like

public subclass extends Room
{
public subclass(String building, String roomNumber, int capacity)
{
super (building, roomNumber, capacity);
}





also about the printing method i got a toString method to print the Room class
toString for Room class
public String toString()
{
return(Building+"|"+RoomNumber+"|"+Capacity);
}// toString

toString for subclass
{
return ("L"+super.toString()+"fire")
}
is that right for the toString for the sub class ?

Reply With Quote
  #4  
Old May 4th, 2008, 10:12 PM
spywx2003 spywx2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 5 spywx2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 37 m 38 sec
Reputation Power: 0
i figured it out ...thanks for your help everything is ok now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - Using "super()"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway