Skip to content

Class Diagram and Class Relationships

UML Representation

Pasted image 20260215193006.png

Pasted image 20260215193241.png

  • An instance of an association
  • Exists between two or more objects

Pasted image 20260215200223.png

public class Member {
    private Book book;
    void issueBook(Book b) {
        this.book = b;
        b.setLender(this);
    }
}
public class Book {
    private Member member;
    void setLender(Book b) {
        member = b;
    }
}

Qualified Association

Using a unique identifier to represent an association

Pasted image 20260215215024.png

Pasted image 20260215215218.png

public class League {
    private Map players;
    void addPlayer(String name, Player p) {
        players.put(name, p);
        p.addLeague(nickName, this);
    }
}

public class Player {
    private Map league;
    void addLeague(String nickName, League l) {
        league.put(l, nickName);
        l.addPlayer(nickName, this);
    }
}

Interface

A strict contract that is implemented by classes. Must override the defined methods

Pasted image 20260215224623.png

Pasted image 20260215224729.png

Abstract Class

A restricted base class that cannot be directly instantiated and is designed to inherited

  • Reduces complexity
  • Increases flexibility

Pasted image 20260216231757.png