Attribute Implementation

Before starting this lab, you must read the chapter Correspondance entre modèles de conception UML et le code: aspects structurels.

Use Java to implement the UML Class Event and its attributes. Use the Getter/Setter implementation strategy introduced during the lectures.

  • For executing the JUnit tests for this lab, execute the following command in the project root folder:

mvn package -PAttributes
svg

Open the Maven module named attributes. Part of the implementation is already done: a Java enumeration named AlarmKind, a Java interface named Event, and several unit tests (see class SimpleEventTest). There is also a partial implementation of the class SimpleEvent.

You have to complete this class:
  1. First, declare the needed Java fields. All fields must be private.

  2. Then, implement the class constructor. Remember that some attributes are mandatory and others are not. The constructor must throw a IllegalArgumentException if the arguments are invalid.

  3. After, implement the fields' accessors and modifiers (getters and setters).

  4. Run all tests. Once all tests pass, you are finished.