Knowledge Guide
HomeOO & Low-Level DesignOO Design Problems

Design Cricinfo

Let's design Cricinfo.

Cricinfo is a sports news website exclusively for the game of cricket. The site features live coverage of cricket matches containing ball-by-ball commentary and a database for all the historic matches. The site also provides news and articles about cricket.

Image
Image

System Requirements

We will focus on the following set of requirements while designing Cricinfo:

  1. The system should keep track of all cricket-playing teams and their matches.

  2. The system should show live ball-by-ball commentary of cricket matches.

  3. All international cricket rules should be followed.

  4. Any team playing a tournament will announce a squad (a set of players) for the tournament.

  5. For each match, both teams will announce their playing-eleven from the tournament squad.

  6. The system should be able to record stats about players, matches, and tournaments.

  7. The system should be able to answer global stats queries like, "Who is the highest wicket taker of all time?", "Who has scored maximum numbers of 100s in test matches?", etc.

  8. The system should keep track of all ODI, Test and T20 matches.

Use case diagram

We have two main Actors in our system:

Here are the top use cases of our system:

Image
Image

Class diagram

Here are the main classes of the Cricinfo system:

Image
Image
Image
Image

Activity diagrams

Record a Ball of an Over: Here are the steps to record a ball of an over in the system:

Image
Image

Code

Here is the high-level definition for the classes described above.

Enums, data types, and constants: Here are the required enums, data types, and constants:

java
public class Address {
    private String streetAddress;
    private String city;
    private String state;
    private String zipCode;
    private String country;
}

public class Person {
    private String name;
    private Address address;
    private String email;
    private String phone;
}

public enum MatchFormat {
    ODI,
    T20,
    TEST
}

public enum MatchResult {
    LIVE,
    FINISHED,
    DRAWN,
    CANCELED
}

public enum UmpireType {
    FIELD,
    RESERVED,
    TV
}

public enum WicketType {
    BOLD,
    CAUGHT,
    STUMPED,
    RUN_OUT,
    LBW,
    RETIRED_HURT,
    HIT_WICKET,
    OBSTRUCTING
}

public enum BallType {
    NORMAL,
    WIDE,
    WICKET,
    NO_BALL
}

public enum RunType {
    NORMAL,
    FOUR,
    SIX,
    LEG_BYE,
    BYE,
    NO_BALL,
    OVERTHROW
}

Admin, Player, Umpire, Referee, and Commentator: These classes represent the different people that interact with our system:

java
// For simplicity, we are not defining getter and setter functions. The reader can
// assume that all class attributes are private and accessed through their respective
// public getter method and modified only through their public setter method.

public class Player {
    private Person person;
    private ArrayList<PlayerContract> contracts;

    public boolean addContract();
}

public class Admin {
    private Person person;

    public boolean addMatch(Match match);

    public boolean addTeam(Team team);

    public boolean addTournament(Tournament tournament);
}

public class Umpire {
    private Person person;

    public boolean assignMatch(Match match);
}

public class Referee {
    private Person person;

    public boolean assignMatch(Match match);
}

public class Commentator {
    private Person person;

    public boolean assignMatch(Match match);
}

Team, TournamentSquad, and Playing11: Team will announce a squad for a tournament, out of which, the playing 11 will be chosen:

java
public class Team {
    private String name;
    private List<Player> players;
    private List<News> news;
    private Coach coach;

    public boolean addTournamentSquad(TournamentSquad tournamentSquad);

    public boolean addPlayer(Player player);

    public boolean addNews(News news);
}

public class TournamentSquad {
    private List<Player> players;
    private List<TournamentStat> tournamentStats;

    public boolean addPlayer(Player player);
}

public class Playing11 {
    private List<Player> players;
    private Player twelfthMan;

    public boolean addPlayer(Player player);
}

Over, Ball, Wicket, Commentary, Inning, and Match: Match will be an abstract class, extended by ODI, Test, and T20:

java
public class Over {
    private int number;
    private List<Ball> balls;

    public boolean addBall(Ball ball);
}

public class Ball {
    private Player balledBy;
    private Player playedBy;
    private BallType type;

    private Wicket wicket;
    private List<Run> runs;
    private Commentary commentary;

}

public class Wicket {
    private WicketType wicketType;
    private Player playerOut;
    private Player caughtBy;
    private Player runoutBy;
    private Player stumpedBy;
}

public class Commentary {
    private String text;
    private Date createdAt;
    private Commentator createdBy;
}

public class Inning {
    private int number;
    private Date startTime;
    private List<Over> overs;

    public boolean addOver(Over over);
}

public abstract class Match {
    private int number;
    private Date startTime;
    private MatchResult result;

    private Playing11[] teams;
    private List<Inning> innings;
    private List<Umpire> umpires;
    private Referee referee;
    private List<Commentator> commentators;
    private List<MatchStat> matchStats;

    public boolean assignStadium(Stadium stadium);

    public boolean assignReferee(Referee referee);
}

public class ODI extends Match {
    // ...
}

public class Test extends Match {
    // ...
}
🤖 Don't fully get this? Learn it with Claude

Stuck on Design Cricinfo? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Design Cricinfo** (OO & Low-Level Design) and want to truly understand it. Explain Design Cricinfo from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Design Cricinfo** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Design Cricinfo** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Design Cricinfo** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes