Lesson 6

Java collections

Objectives

Understanding collection types:

  • Lists
  • Sets
  • Maps

Documentation

Exercises

Exercises 1

Change 'BirdControler' application from section polimorfism so that it stores all birds in an ArrayList collection.

Exercise 2

Starting from the previous exercise, add a name attribute which can store a name for each bird. Display a sorted lists of birds by their names. Use Comparable interface to implement this exercise.

Exercise 3

Update 'Dictionar' application from section Colectii so that it can remove a word from the dictionary.

Exercise 4

Create a simulator for a road traffic crossroad. Each road is composed of one input lane and one output lane. Model input lanes using LinkedList collection class. Chars which are exiting the crossroad are removed from system. There should be a counter for each output lane containing the number of cars which exited that lane.

Create the class diagram and implement java application for the simulator.

Exercise 5

Create a students catalog for a course which provide following functions:

  • add students to catalog
  • add student final exam grade (expressed as integer number in interval [1-10])
  • add student lab grade (expressed as integer number in interval [1-10])
  • calculate and display average grade for all students in catalog
  • calculate and display average grade for a student by his name
  • remove student from catalog by name
  • return a sorted list of students in alphabetical order
  • return a sorted list of students descending by their final exam grade
  • return a sorted list of students descending by their birth date