本文共 4006 字,大约阅读时间需要 13 分钟。
在“旅店管理中的类的概述”完成之后,我又仔细的审查了自己关于各个类的定义,我发现自己竟不知不觉地走入了(Enterprise Bean)的范畴,从我在前文中定义的概念可以看出其中房间信息,预定信息以及租用信息属于EJB中的实体Bean(确切地说应该是实体Bean中的Bean类我将它称之为实体类),而管理人员和旅店服务人员应该是EJB中的会话Bean中的Bean类(我在这把它叫做会话类)。(另外查询信息,是一个没有很好地解释的类,正像前面说得那样,这个类的存在与否是一个问题所在。)我不知道别人在实际的实际过程中会不会出现这样的情况,是我感到疑问的是在没有出现EJB之前,设计者在分析设计的过程中也会得到这样的结果吗?如果是这样的话,EJB这种概念应该是在java出现之前就应该出现,是不是像我说得这样呢?希望那位知道的读者告诉我关于OO的设计过程中是不是很早就提出了这种对于的分类。
而如果情况真的如我分析的那样的话,我们在实体类中就没有过多的内容要详细描述(可能会在的定义之后进行详细地描述),因为实体Bean的作用主要是想JC或者其他一些后端的经常访问的数据提供一个面向对象的接口,也就是说实体类其实是对数据库的内容在程序中的一种体现。当然我们在具体实现的过程中可能会使用特殊的处理手段,比如将某字段作为对象单独处理等。我在下面只是简单得给这些类(本以为这些内容会以接口的形式存在,从而便与支持,不想不知不觉走入了EJB的范畴,)一个名字以供下面的内容使用。
1、房间信息:RoomInfo
2、预定信息:ReserveInfo3、租用信息:RentInfo接着我们来处理一下旅店服务员这个主要的会话对象的主要几个功能,并把它们定义成旅店服务员的方法(关于管理员的查询以后再作补充)。
我们先为旅店服务员着个类起名为HostelClerk,一下是HotelClerk类的主要部分(没有提供对于会话Bean接口的实现)。
import java.util.*;
/*
* Created on -7-28 *//**
* This class is used in Hostel MIS. It is the class which implements * room renting, reserving, check out and other main function. * * @author idilent */public class HostelClerk {/**
* This method is used to get the available rooms when the clerk * reserves or rents room for the custommer. * * @param roomPrice the price of the room * @param fromDate the date from which the room will be rented * @param toDate the date to which the room will be rented * @return the available rooms. * * there may be should a class call SearchCondition which encapsulates * the search conditions * */ public RoomInfo[] availableRooms(Currency roomPrice,Date fromDate,Date toDate){ return null; } /** * This method is used to rent a room,since the availableRooms method had to be * called before this function(else you will have no a of which room is availble * to rent), so we can get a roomID fothe RoomInfo[] which is the result of * availableRooms method. * * @param roomID the roomID is the primary key of the room information * @param fromDate the date from which the room will be rented * @param toDate the date to which the room will be rented * @param customerName the customer's name, there should be other information of * the customer. Maybe a class which supports the customer infor is needed. */ public void rentRoom(int roomID, Date fromDate, Date toDate, String customerName){ } /** * This method is used to reserve a room,since the availableRooms method had to be * called before this function(else you will have no idea of which room is availble * to rent), so we can get a roomID form the RoomInfo[] which is the result of * availableRooms method. * * @param roomID the roomID is the primary key of the room information * @param fromDate the date from which the room will be rented * @param toDate the date to which the room will be rented * @param customerName the customer's name, there should be other information of * the customer. Maybe a class which supports the customer infor is needed. */ public void reserveRoom(int roomID,Date fromDate, Date toDate ,String customerName){ } /** * * used to cancel reservation, if the customer remebered the reserveInID. * * @param reserveInfoID the primary key of reserveInfo. */ public void cancelReservation(int reserveInfoID){ } /** * used to cancel reservation when the customer forget the reserveInfoID * Of course he should remeber his name though he could forget anything. * * @param customName supports the search the reserveInfo which should be canceled. */ public void cancelReservation(String customName){ } /** * used to check out. * * @param RoomID the roomInfo primary key * * Do you think there should be another version of the checkOut? * maybe, but I think the roomID is always available. It may be the room's key name. */ public void checkOut(int RoomID){ } }好了,这个旅店系统的开发文档就在这里告一段落。其中内容必然让所有的人大失所望。但是这也不是我希望的结果。无论如何,谢谢大家。
版权所有:idilent 网站转载请注明作者 其他转载方式请与作者联系(to:idilent@.com.cn">idilent@yahoo.com.cn)。来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-960971/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10748419/viewspace-960971/