Skip to content

4.10 Tutorial 6

Task 1

Consider project music-album​ accompanying this guide. In class Track​ complete the following tasks:

  • SubTask 1: Add the class invariant to the class documentation.
  • SubTask 2: Add any missing pre/postconditions.
  • SubTask 3: Implement all incomplete methods, use exceptions to check pre/postconditions.

Task 2

Consider project music-album​ accompanying this guide. In class Album​ complete the following tasks:

  • SubTask 1: Add the class invariant to the class documentation.
  • SubTask 2: Add any missing pre/postconditions.
  • SubTask 3: Implement all incomplete methods, use exceptions to check pre/postconditions.

Task 3

Consider classes Track​ and Album​ from previous exercises. Implement at least two tests for each method of these classes. Clearly distinguish each part of each test (Arrange, Act, and Assert). Implement both positive and negative tests.


Task 4

Consider from the previous guide, all methods related to arrays, extend these methods with lineal and dichotomic search methods, in int​ arrays. Methods must have proper documentation, including pre and postconditions, and the method must implement pre and postconditions checks using exceptions.


Task 5

Consider from the previous guide, all methods related to arrays, extend these methods with insertion and selection sorting methods, for int​ arrays. Methods must have proper documentation, including pre and postconditions, and the method must implement pre and postconditions checks using exceptions.


Task 6

Consider from the previous guide, all methods related to arrays, extend these methods with random permutation and Ordered combination (merge) methods, for int​ arrays. Methods must have proper documentation, including pre and postconditions, and the method must implement pre and postconditions checks using exceptions.


Task 7

Define a class ListUtils​, containing utilities methods for lists. Implement the following methods with their respective documentation, including pre and postconditions:

  • SubTask 1: Search for an element using lineal search.
  • SubTask 2: Search for an element using dichotomic search.
  • SubTask 3: Order a list using insertion sort.
  • SubTask 4: Order a list using selection sort.
  • SubTask 5: Random permutation of the elements of a list.
  • SubTask 6: Merge the elements, in order, of two ordered lists.