Eamon Nixon

Greenhorn
+ Follow
since Jun 30, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eamon Nixon

Junilu Lacar wrote:


2. Customers -> Makereserve and cancelreserve. These are not the responsibilities of a Customer, even though it's what a real-world customer would do. In fact, you have to ask whether it is the customer who actually does the making and canceling of reservations in a hotel reservation system. Take a hint from the names... it tells you the class to which the Make and Cancel operations should be assigned.



I see what you mean, a customer probably has only create, set, get methods.

Junilu Lacar wrote:
3. Reception is a customer. Again, you are falling into the trap of trying to model your classes too closely to the real world. Object-orientation is not so much about modeling the real world as it is about assigning responsibilities to the correct classes. The classes you come up with may or may not be somewhat similar to real-world objects but often they are really abstractions of actions and relationships that are not exactly like they are in the real world.


So basically so far, I have identified a few of the likely classes in the system. Customer, room, reservation, hotel. Manager, receptionist are possibilinties.
Find reservations, this should be the responsibility of reserve class.
Find customers, this should be the responsibility of ???.
Find rooms, this should be the responsibility of ???.
Find room price, room responsibility.
Now, I should list data requests like this and see who could answer those requests. Find cheapest room, I will have to find all room objects and then get the lowest for the room.getprice().

Junilu Lacar wrote:
4. Manager is a receptionist. If you are thinking inheritance here, then it's wrong. This will be an incorrect crossing of two separate roles: the Manager role and the Receptionist role. Rather, a User of your system can accomplish tasks interesting to a Manager or tasks that are interesting to a Receptionist.


Interesting to a manager, I have not come across this before. Do you mean like Print to file will be a common method, so it should be an interface.

Junilu Lacar wrote:
I strongly encourage to develop your design incrementally and in a Test-Driven manner. If you do Test-Driven Development properly, you will get to see the interactions between classes more clearly and see if production code will make sense and if it can be maintained and extended easily. You can also refactor your design as you go and discover more details about the interactions and relationships you want to model in code.


Test-Driven is agile. Write your tests first. TDD would make a lot of sense and seems logical. "It all works perfectly on paper, so it must have been implemented incorrectly". And also, puts huge pressure on designers. "Mail Order a bride" is another pillar of TDD, I was promised everything and she doesn't know how to use a toilet.
Thanks for the book reference, I probably read more than code is my problem. Once I start coding, I stop all else and force squares into circles. "It works" Stupid approach I know.

Thanks for the advice and help. I see a lot clearer know. Customer class should be Customer Data. Sets and Gets methods. Hotel class. Hotel Data. Sets and Gets.
reservation class. Room objects, date, Customer object. Gets() Sets()
Reserve class. reservation object. cancel add remove.
RoomReserve class. room objects. reservation objects. getBooked(type,dates) getAvailable(type,dates) getAllRooms()
The idea is data and responsibility grouping, so an object is fully equipped to survive alone. The object has its data and uses its data simply. Kinda like name and serial number, it cant do much damage if it doesn't know too much about anything else.
Thanks also Junilu for not explicitly correcting my mistakes, as I would have gained nothing from that. I especially appreciate that extra effort on your behalf.
Hi All,
I have an OO design which has identified inheritance, aggregation for a hotel system.
Hotel has rooms. Responsibility. Sendrooms, Sendcustomers, maintain hotel info.
Room is a single. Maintain single room info.
Room is a double. Maintain double room info.
Hotel has Customers.
Customers. Maintain customer info. Makereserve, cancelreserve.
Receptionist is a customer. (Can do all behaviours of customer) checkIn(), checkOut().
Manager is a receptionist. Reports()
Reservations have reserveLines. Maintain reservation info.
ReserveLines have rooms. Maintain reserveLine info.


This has helped me identify classes and some design. Great and some logic also for the system.
However, for a use case such as Make reservation, I have no idea how to accomplish it. I need to know what existing reservations there are. e.d single rooms available for July12th.
SingleRoomsAvailable(dates) and doubleRoomsAvailable(dates). I have looked at some MVC material and this is what I'm attempting to do, I think. The above classes are the model. I'm not too concerned with the view, but the controller is my problem, again I think.
The view will provide me with Customer, dates and room types. These are sent to control, lets call it Booking system, Booking system, checks availability of rooms for dates, then customer can create a reservation object with reserveLines for each date-room pair and writes the reservation to file and writes the reserveLine to file.
So, Does the Booking system interacts with rooms via hotel file and get room info, then
The booking system interacts with booked rooms via reserveLine data file and gets booked room info for dates.
The booking system will also need to interact with reservation file and customer file to get a reservation for a customer.
Booking system's responsibilies Getavailablerooms(). Getreservation(). GetCustomer(). It seems a lot for one class to cover.
From these responsibilies, I can makereserve(), cancelreserve() checkin()
As always thanks for reading, as I can imagine how frustrating "and LONG" this is to read for you guys.
I have ordered Martin fowler Object Primer, as OO concepts are proving a little more complicated than expected or else I'm a little dumber than I thought. Any other advice on reading would be appreciated. I kinda feel I have a lot more reading to do to make the next step, but what to read up on??





Campbell Ritchie wrote:Welcome to the Ranch
You should be learning Java and design in parallel. You cant do advanced Java without something to program and you cant program anything unless you have designed it.
I agree with John McClellan that you are over thinking this problem. You should develop it incrementally. Designing it in terms of sending a message to find which rooms are available” is not part of the basic design, but an implementation detail, which you can work out later. Getting a list of available rooms is not necessarily part of the booking process. Getting, “Yes, we can accommodate four people from 18th July until 21st July is.
Stop thinking in terms of programming. think how you would model a reservation for a particular room from 18th to 21st July on paper. Then think how that can be programmed. The more you do on paper, the easier the programming task will be.

Start with a room, and decided what its attributes are. Probably number of beds and some way of relating the guest to dates. You may not need any more for a room at this stage. Get that working. Then adding the rooms to make up a hotel is an enhancement of what you already have. Remember number of rooms is an attribute of a hotel. You can have hotels with 25 rooms or 250 rooms.



I think I know what you mean. On paper. A reservation should have a

1) Example
RESERVATION
reserveID ; reserveName ; Ccard ; CheckInDate ; CheckoutDate; NumRooms ; NumNights; TotalCost CheckedIn Checkedout
11 Eamon 2354 21st 23rd 1 2 150 No No

ReserveDetail
roomNum ; numGuests, GuestName ; Date ; roomType; Price ; ReserveID

3 2 J&N 21 Double 75 11
3 2 J&N 22 Double 75 11

ROOMBookings
RoomNum DatesBooked ReserveID
Room 3 21st July 11
Room 3 22nd July 11


The above example is fairly straightforward. 1 room booked for 2 nights.

But the reservation below is a little bit more complicated as it has 2 rooms booked for different durations. One room for one night and one room for 2 nights. I want to design a system which allows for multiple room bookings.


2) Example
RESERVATION
reserveID ; reserveName ; BookingCcard ; CheckInDate ; CheckoutDate; NumRooms ; NumNights; TotalCost
11 Eamon 2354 21st 23rd 2 3 200

ReserveDetails
roomNum ; numGuests, GuestName ; Date ; roomType; Price ; ReserveID CheckedIn Checkedout PaymentDetails

3 2 J&N 21 Double 75 11 No No
3 2 J&N 22 Double 75 11 No No
***********************************************************
2 1 Tom 22 Single 50 11 No No

ROOMBookings
RoomNum Date ReserveID
Room 3 21st July 11
Room 3 22nd July 11
Room 2 21st July 11

In this example, checkin would have to be with individual room rather than with reservation, room 3 and 2 are checkedIn. Also, you have the similar problem with checkedOut to Yes. Now, I have problems with payment. Perhaps J&N and Tom want to pay seperately.

Checking Out

2) Example
RESERVATION
reserveID ; reserveName ; BookingCcard ; CheckInDate ; CheckoutDate; NumRooms ; NumNights; TotalCost
11 Eamon 2354 21st 23rd 2 3 200

ReserveDetails
roomNum ; numGuests, GuestName ; Date ; roomType; Price ; ReserveID CheckedIn Checkedout Paid

3 2 J&N 21 Double 75 11 Yes No No
3 2 J&N 22 Double 75 11 Yes No No
***********************************************************
2 1 Tom 22 Single 50 11 Yes No No


J&N decide to checkout and only pay for their room.
PaymentDetails
roomNum ; GuestName ; Nights; roomType; Cost; ReserveID Checkedout Ccard Paid


3 J&N 2 Double 150 11 Yes 126 Yes
2 Tom 1 Single 50 11 No No

Now Tom arrives to checkout.

ReserveDetails
roomNum ; numGuests, GuestName ; Date ; roomType; Price ; ReserveID CheckedIn Checkedout Paid

3 2 J&N 21 Double 75 11 Yes Yes Yes
3 2 J&N 22 Double 75 11 Yes Yes Yes

***********************************************************
2 1 Tom 21 Single 50 11 Yes No No

PaymentDetails
roomNum ; GuestName ; Nights; roomType; Cost; ReserveID Checkedout Ccard Paid


2 Tom 1 Single 50 11 Yes 456 Yes

Is this what I should be doing with all my use cases. Make Reservation. check In, Check Out, Payment, Cancel Reservation. when I am finished my use cases, I will know WHAT I need to be able to do but not HOW to do it.

What data it needs to complete each use case?
NOT
HOW to complete the use cases.

John McClellan wrote:In a way you're thinking of it in excessively technical terms. Don't. You're also trying to copycat over from a different (thought slightly similar) problem. Don't.

Basically the whole idea behind using objects is to be able to model the problem in your code instinctively and naturally, much like it is in the natural world. If you're trying to come up with a class model or something in some really technical way for a very simple, natural problem like this, then you're not thinking about objects instinctively and naturally enough.

As for trying to pull from a library example, doing stuff like that is really more for learning a language or an API or something; it isn't something you want to do very much when going from one problem space to another. Admittedly it can be a good idea sometimes, but imagine the difference in the real world between checking out a book in a library and renting a room at a hotel. They're a little bit similar, but still pretty different. So in the real world, if you managed a library and started managing a hotel, you might take a few good ideas with you, but you wouldn't want to get too obsessed with using a really similar technique. Kind of the same idea here.



I know you are right, but I think I'm trying to persuade myself that I have some understanding of the solution through the library example. This is entirely new territory for me as you can see. I need to let go of technical problems at this stage and just model the system based on real world responsibilities, roles and data. Is that a correct assumption?
I have used databases before and keep thinking about storing data and where to find data, this isn't helping, but hindering me.

As for the old world system, I do remember that and now I see the system a little better. As the old world system worked, you would call a hotel. Hotel class. A receptionist would answer, find an available room,Room and Reserve Agent class, ask me if I wish to proceed, then make a reservation for me. Reservation class.

As I would see this now,
Hotel class maintains hotel information, number and types of rooms.
Reserve Agent. Finds available rooms and makes reservations.
Room class. Maintains room data.
Reservation class. Maintains reservation data.
RoomBooking class, Maintains data about each room booking.

How does that look?

I am confused now about 2 things above.
1) A reserve agent class gets a request for booking these dates from a customer, 10/11/12 , 11/12/12, 12/12/12 for a double room. It sends a message to rooms class, please return all double room numbers(201,202,203 etc). Now it sends room booking class the (dates and all double room numbers) to see what rooms are booked for those dates?
When the message(return double rooms) is sent to rooms and there are 20 double rooms in the hotel, will there be 20 room objects created? or just 1 room object, then checked for availability on room booking class, destroyed if not available and another room object created and checked for availability, destroyed if not available and so on until an available room is found and returned to reserveAgent class.
2) If I have one reservation object for a customer, then I could have 10 related Room Booking objects as I can have many bookings for one reservation, so I would have NumRoomBookings=10 as an instance variable of reservation. I know this is getting too technical for class models, but I'm just curious.
Everything else above is simple and straightforward.Lol.

Thanks for your help guys also. Appreciated.

As an excuse for this thread, I dont only want to get to know Java in detail(although that would be great) without having some software design understanding also. I'm kinda hoping to step through some UML class models, interaction diagrams, use cases etc and Java at the same time. Any thoughts on this idea would be welcome also.
3) Do you think I should just concentrate on learning Java in more detail first and then consider design issues?
Lots of questions, maybe this should be a different thread?







Hi,
I am using a library system example to design a hotel reservation system. I can understand the concept or use case for the library system like this. Member takes book to desk to borrow book. Gives member number. The member object checks to see if the guy has fines or too many books already. If everything checks out, he borrows book. Thats fine, I understand the concept here. You have Member class, Book class and CopyOfBook class. Member sends message to copy, copy send message to Book.
The hotel system is similar. However the customer essentially takes a room Type= Single and a date=12/12/12 to the desk similar to the book scenario above. Where do I send this information to check that its Ok and get a room number?
Like the book scenario above, I need to change Single+ 12/12/12 to a room number.
For example 12/12/12+single becomes Room 4. Reservation sends room 4 a message you are booked for 12/12/12. How does 12/12/12+single become Room 4?
The system needs to know
Single rooms available for that date, so it can give me room 4 to replace 12/12/12+Single and room 4 + date I need to proceed with a reservation.

OO concept difficulty
I have a hotel class with information on how many bedrooms, meeting rooms etc. I think I will only ever have one hotel object.
I have a room class which gives details about the rooms, double-single, room numbers. For rooms I can have 50 objects, one for each room.

I need a class with the responsibility for available Rooms. Rooms is not responsible for that and Hotel is not responsible for that. Is reservation responsible? That doesn't seem correct to have reservation responsible for available rooms.
I have 50 rooms in my hotel, so I can have 50 room objects. 25 Single, 25 double. I'm thinking databases, but I know my concept is wrong. So the only information I can get from room is a single or double room. I want a single room.
I'm sure you can easily see my confusion. Lol
But can you throw me an example or scenario which might ease my pain?
I simply dont see where to get an available room for a specific date and type from. Also, I'm not using a database, but I'm sure I should not be thinking databases when working out class models or interaction diagrams. Unfortunately, I dont yet understand objects. Trust me I have read about encapsulation, inheritance, interfaces etc, but the concept hasn't permeated the pygmy peanut yet.
Thanks for reading my rantings as I realise this is not Java specific.
Eamon
Thanks Gents. I'll take a look at those links.
11 years ago
Hi,
I have some programming experience only with databases but not OO programming, but I am trying to create a Library system. Loans and LoanLine has a 1.....* relationship. Thats fine. I know this unique fields and auto incremenets etc.
However, I'm trying to use a CSV file because its alien to me. Seems stupid as I know databases, yes probably is, but cant learn what I already know.
If I create a Loan file, how do I keep a unique Loan ID? or does Java have a wonderful API to help me do this CSV file stuff?
I will need two CSV files, Loan and LoanLine which will correspond to objects/classes.
e.g Loan file
1,Tom;
The LoanLine file
1, 1, Rocky,07/07/12;
1, 2, Matrix,07/07/12;
Tom takes out 2 dvds.

How do I create my next Loan as I will need to know the Loan file already contains #1.
The only way is to read the last line of the Loan file and get value up to the comma, then add 1 to this number when I create a new Loan object?
Create Loan object.
Read Loan file, get last number, add 1 for the ID.
Now create LoanLine object.
I'm not expecting a thorough explanation, but if somebody could point me in the right direction. Read up on String buffer or IO file or read up on ****, that would be fantastic and much appreciated.
My problem in summary is doing the stuff that database usually do with indexes and primary and foreign keys.
How will I check that a Dvd is not out on Loan?
Search for "Matrix,07/07/12" and if it doesn't exist in LoanLine, its available. Loanline is linked to movies.
Does Java have a special API that makes all this reading and writing to CSV files easy? This is basically my question. I'm also still at the design stage of classes and the reading and writing from csv files to objects is confusing me.
I hope this makes sense to someone. Lol


11 years ago

Campbell Ritchie wrote:

Anayonkar Shivalkar wrote: . . . That is, your classpath should contain parent directory of dotcombust (instead of dotcombust itself). . . .

Disagree.

It is usually best not to set a system classpath at all, but some applications set it for you while you aren’t watching. QuickTime is notorious for doing that. Delete the references to dotcom, test project and the jdk from the classpath. They should not be in a system classpath. If you need a classpath, you should set it with the -cp tags. If you are at the dotcom stage, you don’t yet need to know about -cp. Change your classpath to read

CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

Note the .; at the beginning. That will take you to your “current” directory as a default, which is what you usually want.
You will have to navigate to the correct directory for dotcom. I would suggest you //comment out the package names from all your dotcom classes and use the directory they are in as an unnamed package.


Great Stuff..
//commented the package reference
Added .; as current directory classpath and deleted the others.
Thanks for tutorial link on packages also. I do read these things.
Works perfectly, never would have figured it out. Forums, wonderful places.
Great Welcome gentlemen.
Thanks for your help. Can move on to next 5 meter wall now. Then, I'll be back.
Dont worry ranch hands, I search the forums for answers before I post.
11 years ago
Hi,
I have the following Classpath

*******************************************************************
CLASSPATH=C:\Users\Beatrice\Documents\NetBeansProjects\DotComBust\src\dotcombust
\;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\Java\jdk1.6.0_3
0\bin;c:\testProject
*******************************************************************************

I have already compiled GameHelper.java to GameHelper.class AND
DotCom.java to DotCom.class and both C;ass files INTO
c:\testProject

Now I try to compile DotComBust.java also in c:\testProject which implements the previous 2 classes(GameHelper+DotCom), but it gives me compile errors on all references to GameHelper and DotCom.

****************************************************************************************
C:\testProject>javac -cp . DotComBust.java
DotComBust.java:21: cannot find symbol
symbol : class GameHelper
location: class dotcombust.DotComBust
private GameHelper helper = new GameHelper();
^
DotComBust.java:22: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
private ArrayList<DotCom> dotComList = new ArrayList<DotCom>();
^
DotComBust.java:21: cannot find symbol
symbol : class GameHelper
location: class dotcombust.DotComBust
private GameHelper helper = new GameHelper();
^
DotComBust.java:22: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
private ArrayList<DotCom> dotComList = new ArrayList<DotCom>();
^
DotComBust.java:27: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom one = new DotCom();
^
DotComBust.java:27: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom one = new DotCom();
^
DotComBust.java:29: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom two = new DotCom();
^
DotComBust.java:29: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom two = new DotCom();
^
DotComBust.java:31: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom three = new DotCom();
^
DotComBust.java:31: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
DotCom three = new DotCom();
^
DotComBust.java:38: cannot find symbol
symbol : class DotCom
location: class dotcombust.DotComBust
for (DotCom dotComToSet : dotComList) {
^
11 errors
**************************************************************************************************************************

I have the correct classpath, but JAVAC isn't finding the classes.
I've tried javac -cp . DotComBust.java.
Any help would be appreciated?

11 years ago