Lompat ke konten Lompat ke sidebar Lompat ke footer

Uml Class Diagram For Flight

Here is a homework sample:

The singleton pattern

A singleton is a pattern for a class that ensures that there will be only one instance of the class at global scope. A singleton class is used when there must be only one instance of a class accessible by a client from a known location. Another use is when the single instance should be extensible by inheritance and clients need to be able to use the extended instance without modifying their code.

Why use a singleton? Consider an operating system in which you want to ensure there is only one file system, print spooler, and view manager. A business system might want to make sure there is only one instance of each customer. Other benefits include the ability to control access to the single instance. This method also reduces the number of global variables in the namespace.

In Smalltalk, the singleton pattern is used by calling the method new only once; after this method is called, every other call to this message will raise an exception. There also should be a method instance, which returns the unique instance of the object.

Let's consider that we want to build an operating system, and we want to define a class for memory, namely Memory. There will be only one object from this class (because we want to keep the system as reliable as possible). To implement that, we add a class varible named Created, which will be initially 0. When the instance of the object is created, the variable is changed into 1. The corresponding Smalltalk code is:

Memory class

new

"Creates the instance of the class; if there is already one, raises an error"

 Created = 0

 ifTrue: [ Created := 1.

          ^self new initialize.]

 ifFalse: [ self error: "This object cannot have two instances!"]

instance

 ^self.

References to related singleton patterns and C++ code: Singleton Pattern

UML Class Association Diagram

CRC Description

  1. Flight: Responsability of FlightRepository; has a number, a departure and arrival date, an itinerary. Also has a associated table with different prices (depending on position of seat, time of yer, etc.). It has also a PassengerList. It has the responsability of associating the passenger with a seat.
  2. Passenger: has the responsability of tickets; has the responsability of booking, canceling and paying tickets. It has an associated identity (Name. address, identity card, creditcard number info). The communication between Passenger and tickets is done through another class: Booking (not shown). This can be a holder for three classes: (Telephone, WebPage, AutomatedTelephone). Passenger might be a client of this class.
  3. FlightSegmentReservation: Represents a segment of a flight. Has the resposability of noticing the flight about the passenger 's actions. Therefore, it is interfacing a passenger with a flight. Also it's useful for computing the price of the ticket (because can ask the flight instance for the price of its current category). It is good also if one wants to book mixt segments (car, boat, plane, train); each one can be linked to a different "server".
  4. Ticket: is a collection of FlightSegmentReservation. Has the responsability for booking/canceling flight reservation, change of itinerary and computing the price for the passenger. It is the responsability of class Passenger.
  5. Itinerary:holds the itinerary of the plane, in pairs(departurePoint, arrivalPoint). It is the responsability of Flight. It was introduced for maintainabillity reasons (it might change).
  6. DepartureOrArrivalDate: represents the exact date (date and time) of the departure / arrival of the plane. It is the responsability of Flight.
  7. Seat: Represents the actual position in the plane (number) of a seat. It is the responsability of PassangerList.
  8. PassengerList: represents the association between the passengers and their seats. It is an association between passengers and seats.
  9. FlightRepository: it is the central database with planes. It is inquired by the passenger, when it's making a revervation/cancelation. It has the responsability for flights. It's controlled by a specialized agency.
  10. Fare: it's an association between the type of flight, special date and a price. It is the responsability of Flight, who asks the FlightRepository when creates a Fare.

UML Message Trace Diagram

UML  Object Message Diagram

Source: https://www.cs.jhu.edu/~rflorian/homework5.html

Posted by: feddesjeffereysays.blogspot.com

Posting Komentar untuk "Uml Class Diagram For Flight"