Free University of Bolzano/Bozen
Faculty of Computer Science - Bachelor in Applied Computer Science
Bachelor in Production Engineering
Introduction to Programming - A.A. 2005/2006

Exercise 4

Class and method definitions

Exercise 4A

Define a class for representing journey tickets. Each ticket should contain the following information:

The Ticket class should have the following methods:

For the design of the class, follow the methodology presented in the lectures.

Solution

Exercise 4B

Define a Java class implementing an example client for the class Ticket of Exercise 4A. The example class should perform the following operations:

Solution

Exercise 4C

Repeat Exercise 4B using the Scanner class to read the input from the keyboard.

Solution