Lab 3
[valid 2025-2026]
Classes and Interfaces
A social network contains persons and companies, each of them identifiable by their unique profile ID.
In this network there are relationships of the following types: person-to-person (if they know each other, how?),
and person-to-company (if the person works for that company, on what position?).
There may be various types of "specialized" persons in the network, such as programmers or designers.
The main specifications of the application are:
Compulsory (1p)
- Create an object-oriented model of the problem. You should have at least the following classes Person, Company.
- Both classes should implement the interface java.util.Comparable. The natural order of the objects will be given by their names.
- Create the interface Profile that defines the methods both Person, Company should have.
The classes above must implement this interface.
- Create a list containing both persons and companies and sort it using a comparator.
Homework (2p)
- Create the complete model: Person, Programmer, Designer, Company. All persons have a birth date.
Each class must have at least one specific property, that others don't have (be creative).
- Each person will contain a Map defining the relathionships to other persons or companies.
- Create the SocialNetwork class containing a list of profiles.
- Create a method that computes the importance of a person or company as the number of its relationships with other persons or companies.
- Create a network object containing persons, companies and relationships and print it on the screen.
When printing the network, the profiles must be ordered according to their importance.
Advanced (2p)
- Implement an efficient agorithm to determine if there are persons or companies in the network that ensure its connectivity,
that is, if they are removed, the social network becomes disconnected.
- Identify maximal parts of the network that, separately taken, do not have such a cut vertex.
- Create JUnit functional tests for your algorithms.
Resources
Objectives
- Create interfaces to describe specifications.
- Create multiple implementations of an interface.
- Understand the differences between abstract classes and interfaces.
- Use packages to organize the classes and intefaces of the application.
- Use collections and generics.
- Use lambda-expressions and streams.
- Understand the space-time tradeoff of various types of collections.