我的酒店类的数组有些麻烦 [英] Having some trouble with arrays for my hotel class

查看:72
本文介绍了我的酒店类的数组有些麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是这个网站的新手,但它看起来确实是一个我会更频繁访问的地方!


解决我的问题。

我正在使用BlueJ在java中创建一个酒店商务项目


课程如下:

酒店 - 优惠酒店的主要功能(即预订的客人,寻找房间等)

房间 - 用于决定房间是否有海景并存放客房内的客人。

Occupier - 有关占用房间的团体的信息,包括住宿晚数和晚餐吃晚餐的方法。


我已经完成了房间和住宿课程,没有任何问题。

我的垮台正在创建酒店课。

到目前为止,该课程有3个字段

展开 | 选择 | Wrap | Line数字

解决方案


另请注意,hasSeaView方法已在Room类中设置。

我已经参考了我的所有工作书并搜索了互联网,但是找不到一个很好的例子来看看这里放什么。


谢谢提前。



请注意,房间不知道它在酒店阵列中的存储位置;你有点b $ b来帮助它w.r.t.有海景。假设一个Room类有两个方法(一个布尔变量的getter和一个setter)

展开 | 选择 | Wrap | 行号


感谢您的帮助到目前为止,但我真正坚持的部分是告诉阵列中的房间,他们在阵列中有关于他们的内容,以便他们可以决定他们是否有海景。但由于数组中的每个条目都被声明为房间对象,我不能直接对它们进行编号。



感谢您的帮助到目前为止,我真正坚持的部分是告诉阵列中的房间,他们可以决定他们是否有海景。但由于数组中的每个条目都被声明为房间对象,因此我无法直接对它们进行编号。



好​​的,第二次尝试;让我们解释另一种方式(参见我之前的回复)。

这里是Room类的相关部分:

展开 | 选择 | Wrap | 行号

First of all I''m new to this site but it certainly looks like a place that i will be visiting more often!

Onto my problem.
I am creating a Hotel Bussiness project in java using BlueJ

The classes are as follows:
Hotel - Deals with the major functions of the hotel (i.e guests booking in, finding rooms etc.)
Room - Used to decide whether a room has a sea view and stores the guest that is in the room.
Occupier - For information about the group occupying a room with methods for amount of nights stayed and nights eaten dinner.


I have completed the Room and Occupier classes with no trouble at all.
My downfall is creating the hotel class.
The class has 3 fields so far they are

Expand|Select|Wrap|Line Numbers

解决方案

Also note that the hasSeaView method has already been set in the Room class.
I have reffered to all of my work books and scoured the interweb but just can''t find a decent example to see what to put here.

Thanks in advance.

Note that a Room doesn''t know where it is stored in your hotel array; you have
to help it a bit w.r.t. having a sea view or not. Suppose a Room class has the
following two methods (a getter and a setter for a boolean variable)

Expand|Select|Wrap|Line Numbers


Thanks for the help so far but the part I''m really stuck on is telling the Rooms in the array where abouts in the array they are so they can decide whether they have a seaview or not. But since each entry in the array is declared as a room object i can''t directly number them.


Thanks for the help so far but the part I''m really stuck on is telling the Rooms in the array where abouts in the array they are so they can decide whether they have a seaview or not. But since each entry in the array is declared as a room object i can''t directly number them.

Ok, second try; lets explain the alternative way (see my previous reply).
Here''s the relevant part of a Room class:

Expand|Select|Wrap|Line Numbers


这篇关于我的酒店类的数组有些麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆