The Artima Developer Community
Sponsored Link

Java Answers Forum
Need help on another complicated question..

6 replies on 1 page. Most recent reply: Nov 13, 2002 7:16 AM by Dante T. Salvador

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
master

Posts: 7
Nickname: masterelr
Registered: Nov, 2002

Need help on another complicated question.. Posted: Nov 4, 2002 11:31 PM
Reply to this message Reply
Advertisement
I've been doing this question for weeks and still can't come up with anythig...hope someone can help me..

- Create a class named HotelRoom that includes an integer field for the room number and a double filed for the nightly rental rate. Include get methods for theses fields, and a constructor that requires an integer argument representing the room number. The constructor sets the room rate bases on the room number; rooms numbered 299 and below are $69.96 per night, others are &89.95 per night. Create an extended class named Suite whose constructor requites a room number and adds a $40.00 surcharge to the regular hotel room rate based on the room number. Write a program to demonstrate creating and using an object of each class.


Daniel Ray

Posts: 53
Nickname: budoray
Registered: Oct, 2002

Re: Need help on another complicated question.. Posted: Nov 6, 2002 8:10 AM
Reply to this message Reply
Do you still need help with this?

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Need help on another complicated question.. Posted: Nov 6, 2002 1:11 PM
Reply to this message Reply
Sounds like it should be a web service. I suggest you install j2ee and create a hotel information mangagement web service. The nice fringe benefit is, not only will you get extra credit on your homework assignment, but you will also be able to sell the thing to all major hotel chains and maybe even retire before the final exam. Report back here with any specific questions.

master

Posts: 7
Nickname: masterelr
Registered: Nov, 2002

Re: Need help on another complicated question.. Posted: Nov 6, 2002 11:54 PM
Reply to this message Reply
Yeah...I still need some help on this question...acutally this is just a simple question which I got asked to do...I'm still scratching my head though...I can only come up with the fields...
All I need is JCreator to run this program...

Chet Underwood, Esq.

Posts: 14
Nickname: chet
Registered: Mar, 2002

Re: Need help on another complicated question.. Posted: Nov 7, 2002 11:11 AM
Reply to this message Reply
You mean it is a simple homework assignment that you were given, don't you? If you've been sitting around for weeks, then you are probably not cut out for programming.

master

Posts: 7
Nickname: masterelr
Registered: Nov, 2002

Re: Need help on another complicated question.. Posted: Nov 7, 2002 9:31 PM
Reply to this message Reply
Well..yeah..it is a homework assignment....I've been doing it for weeks...And I still have about 3 more days before I pass it up..

Dante T. Salvador

Posts: 19
Nickname: anteng
Registered: Nov, 2002

Re: Need help on another complicated question.. Posted: Nov 13, 2002 7:16 AM
Reply to this message Reply

class HotelRoom { // begin HotelRoom class
final double MIN_RATE = 69.89;
final double SPECIAL_RATE = 89.95;
final int ROOM_CRITERIA = 299;

private int room;
private double rentalRate;

HotelRoom ( int intRoom) { // begin HotelRoom constructor
room = intRoom;
if (roomNumber <= ROOM_CRITERIA)
rentalRate = MIN_RATE;
else
rentalRate = SPECIAL_RATE;
} // end HotelRoom constructor
public int getRoom(){ return room; }
public double getRentalRate(){ return rentalRate; }
public void setRoom(int intRoom){ room = intRoom; }
public void setRentalRate(double intRentalRate){ rentalRate = intRentalRate; }
} // end HotelRoom class

class Suite extends HotelRoom { // begin Suite class
final double SURCHARGE = 40.00;
Suite (int roomNumber){ // begin Suite constructor
super(roomNumber); // call HotelRoom constructor
setRentalRate(getRentalRate() + SURCHARGE);
} // end Suite constructor
} // end Suite constructor

public class Assignment { // begin Assignment class
public static void main(String[] args){ // begin main
Suite aSuiteRoom = new Suite(300);
System.out.println("Suite Room Charge ");
System.out.println("Room Number : " + aSuiteRoom.getRoom());
System.out.println("Charge : " + aSuiteRoom.getRentalRate());

Suite anotherSuiteRoom = new Suite(100);
System.out.println("Suite Room Charge ");
System.out.println("Room Number : " + anotherSuiteRoom.getRoom());
System.out.println("Charge : " + anotherSuiteRoom.getRentalRate());

HotelRoom aRoom = new HotelRoom(300);
System.out.println("Suite Room Charge ");
System.out.println("Room Number : " + aRoom.getRoom());
System.out.println("Charge : " + aRoom.getRentalRate());

HotelRoom anotherRoom = new HotelRoom(100);
System.out.println("Hote Room Charge ");
System.out.println("Room Number : " + anotherRoom.getRoom());
System.out.println("Charge : " + anotherRoom.getRentalRate());
} // end main
} // end Assignment class


study more.

Flat View: This topic has 6 replies on 1 page
Topic: do u know any good compilers Previous Topic   Next Topic Topic: Recursive method to find minimum value in an array

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use