Modeling & Implementation

Exercises


Form teams of 4-6 students for the following exercises

These exercises treat the relationship between modeling an application with UML and implementing an application with Java.

Exercises

1.) From an UML class diagram you can extract Java classes and the relationships between them. For each class the class diagram shows the attributes (data members), method signatures, and the relationships (inheritance, association) to other classes. Write down the Java class fragments you can extract from the following diagram. Use at least two operations and two attributes given in the diagram. Discuss different options to represent the relationship between the classes DirectFlight and Airline.

2.) Both UML and Java contain the concept of a package. In this exercise we will consider the relationship between UML package diagrams and Java packages:

a.) Model the following Java packages and classes using an UML package diagram (classes, packages, dependencies).

      package airport.utilities;
      public class DatabaseManager { ... }
      public class PrinterManager { ... }
       
      package airport.database;
      import airport.utilities.DatabaseManager;
      public class Passenger { ... }
      public class Flight { ... }
      
      
      package airport.workflows.passenger;
      
      import airport.utilities.PrinterManager;
      
      import airport.database.*;
      public class StateOfPassenger { ... }
       
      package airport.gui;
      import airport.workflows.*;
      import airport.database.*;
      public class MainWindow { ... }
      public class CheckInWindow { ... 
      

b.) How does the directory structure for these Java packages look like?

3. From UML sequence diagrams you may extract information for the implementation of methods. The following two sequence diagrams show two possible sequences for passenger check-in. In one of the diagrams the ticket check fails. In the other diagram everything goes well. Use these diagrams to complete the method checkIn in the following definition of the class TicketCounter. The other two class definitions show the signatures of the methods called in checkIn.

class Flight {
	
	public int reserveSeat()
	// returns the number of a free seat and reserves it
	{
		...
	}
	
}



class BoardingPass {

	public BoardingPass(int seatNo, Ticket t) 
	// creates a new BoardingPass for the given seat number and ticket data
	{
		...
	}

	public void print()
	// sends the boarding pass data to the printer
	{
		...
	}



class TicketCounter
{

	public boolean check(Ticket t) 
	// returns true if ticket is valid, else false
	{
		...
	}
	
	public Flight getFlight(Ticket t) 
	// returns the flight that can be derived from the ticket data
	{
	  ...
	}
	

	public void showError(String message)
	{
	  ...
	}
	
	public void checkIn(Ticket ticket) {
	
	
	
	
	
	
	
	
	
	



	
	

	
	
	

   }

}



Software Systems Institute

Home of the Java Course Claudia Niederée, Michael Skusa, dec 1999