QUẢN LÝ ĐIỂM SỐ TRẬN ĐẤU THỂ THAO
1. Mục tiêu
Thiết kế chương trình quản lý điểm số cho các trận đấu thể thao, cho phép người dùng nhập thông tin các đội, vận động viên, sự kiện ghi điểm và thống kê kết quả trận đấu. Yêu cầu sử dụng đầy đủ các khái niệm của Lập trình Hướng đối tượng.
2. Danh sách class cần tạo
Class Player
Mục đích: Quản lý thông tin từng vận động viên.
Thuộc tính:
player_id
: int – Mã vận động viênname
: str – Tên vận động viênnumber
: int – Số áoposition
: str – Vị trí thi đấudob
: str – Ngày sinhperformance_score
: float – Điểm phong độ
Phương thức:
__init__()
: khởi tạo thông tin vận động viênupdate_performance(score: float)
: cập nhật điểm phong độget_age()
: trả về tuổi dựa trên ngày sinh
Class Team
Mục đích: Quản lý thông tin đội bóng và danh sách vận động viên.
Thuộc tính:
team_id
: int – Mã độiname
: str – Tên độicoach
: str – Tên huấn luyện viênplayers
: List[Player] – Danh sách cầu thủ
Phương thức:
__init__()
: khởi tạo độiadd_player(player: Player)
: thêm cầu thủ vào độiremove_player(player_id: int)
: xóa cầu thủ khỏi đội theo mãget_player_by_number(number: int)
: trả về cầu thủ có số áo tương ứngget_total_players()
: trả về tổng số cầu thủ trong đội
Class ScoreEvent
Mục đích: Ghi nhận một sự kiện ghi điểm trong trận đấu.
Thuộc tính:
minute
: int – Thời điểm ghi điểm (phút)team
: Team – Đội ghi điểmplayer
: Player | None – Người ghi điểm (nếu có)score_type
: str – Loại điểm: goal, point, spike, v.v.points
: int – Số điểm ghi được
Phương thức:
__init__()
: khởi tạo sự kiện ghi điểmget_description()
: trả về chuỗi mô tả sự kiện
Class Match
Mục đích: Quản lý thông tin và kết quả một trận đấu.
Thuộc tính:
match_id
: int – Mã trận đấuteam1
: Team – Đội thứ nhấtteam2
: Team – Đội thứ haidate
: str – Ngày thi đấulocation
: str – Địa điểmscore_events
: List[ScoreEvent] – Danh sách sự kiện ghi điểm
Phương thức:
__init__()
: khởi tạo trận đấuadd_score_event(event: ScoreEvent)
: thêm sự kiện ghi điểm vào danh sáchget_score()
: trả về tổng điểm của hai đội dạng tuple (score_team1, score_team2)get_winner()
: trả về tên đội thắng, hoặc "Draw"print_match_summary()
: in thông tin tổng hợp trận đấu
Class SportMatchManager
Mục đích: Quản lý toàn bộ hệ thống các trận đấu thể thao.
Thuộc tính:
teams
: List[Team] – Danh sách độimatches
: List[Match] – Danh sách trận đấu
Phương thức:
add_team(team: Team)
: thêm đội mớiget_team_by_name(name: str)
: tìm đội theo tênschedule_match(match: Match)
: thêm trận mớilist_matches()
: hiển thị danh sách các trận đã diễn raget_top_scorer()
: tìm vận động viên ghi nhiều điểm nhất (bonus)get_highest_scoring_match()
: trận đấu có tổng điểm cao nhất (bonus)
3. Yêu cầu lập trình
- Sử dụng
@property
để truy cập dữ liệu hợp lý (ví dụ: tuổi của cầu thủ). - Dùng kế thừa để mở rộng
Match
thànhFootballMatch
,BasketballMatch
, v.v. (tuỳ chọn). - Có thể dùng dictionary hoặc danh sách để lưu trữ các đối tượng.
4. Gợi ý triển khai
Ví dụ sử dụng:
# Khởi tạo cầu thủ
player1 = Player(1, "John", 10, "Striker", "2000-01-01", 8.5)
player2 = Player(2, "Mike", 7, "Midfielder", "1998-03-22", 7.0)
# Tạo đội và thêm cầu thủ
teamA = Team(1, "Lions", "Coach A")
teamA.add_player(player1)
teamA.add_player(player2)
# Tạo trận đấu
match = Match(1001, teamA, teamB, "2025-07-20", "National Stadium")
# Ghi sự kiện điểm
event = ScoreEvent(12, teamA, player1, "goal", 1)
match.add_score_event(event)
# Tính kết quả
print(match.get_score()) # (1, 0)
print(match.get_winner()) # Lions
5. Đầu ra mong muốn
- Hiển thị trận đấu với đầy đủ thông tin đội, điểm số, người ghi điểm.
- Hiển thị danh sách các trận đấu, thống kê tổng điểm.
- Chạy chương trình qua console hoặc menu văn bản (nếu muốn).
Sure. Below is the English version of the detailed OOP assignment requirements for the topic "Sports Match Score Management". It includes a clear breakdown of the required classes, attributes, and methods for use in teaching, assignments, or system design.
DETAILED REQUIREMENTS – SPORTS MATCH SCORE MANAGEMENT
1. Objective
Design an object-oriented program to manage scores of sports matches. The system should allow users to input teams, players, scoring events, and generate results/statistics. Object-Oriented Programming principles must be properly applied.
2. Required Classes
Class Player
Purpose: Manage player information.
Attributes:
player_id
: int – Player IDname
: str – Player namenumber
: int – Jersey numberposition
: str – Playing positiondob
: str – Date of birthperformance_score
: float – Performance rating
Methods:
__init__()
: initialize player infoupdate_performance(score: float)
: update performance ratingget_age()
: calculate player age from date of birth
Class Team
Purpose: Manage team information and player list.
Attributes:
team_id
: int – Team IDname
: str – Team namecoach
: str – Head coachplayers
: List[Player] – List of players
Methods:
__init__()
: initialize teamadd_player(player: Player)
: add a player to the teamremove_player(player_id: int)
: remove a player by IDget_player_by_number(number: int)
: find player by jersey numberget_total_players()
: return number of players in team
Class ScoreEvent
Purpose: Represent a scoring event during a match.
Attributes:
minute
: int – Time of scoring (in minutes)team
: Team – The team that scoredplayer
: Player | None – Player who scored (if applicable)score_type
: str – Type of score: goal, point, spike, etc.points
: int – Number of points scored
Methods:
__init__()
: initialize eventget_description()
: return a description string of the event
Class Match
Purpose: Represent a sports match and manage its outcome.
Attributes:
match_id
: int – Match IDteam1
: Team – First teamteam2
: Team – Second teamdate
: str – Date of matchlocation
: str – Match locationscore_events
: List[ScoreEvent] – List of scoring events
Methods:
__init__()
: initialize matchadd_score_event(event: ScoreEvent)
: add a scoring eventget_score()
: return total score of both teams as a tuple (team1_score, team2_score)get_winner()
: return the name of the winning team or "Draw"print_match_summary()
: print a match summary with all events
Class SportMatchManager
Purpose: Manage all teams and matches in the system.
Attributes:
teams
: List[Team] – List of teamsmatches
: List[Match] – List of matches
Methods:
add_team(team: Team)
: add a new teamget_team_by_name(name: str)
: find a team by nameschedule_match(match: Match)
: add a new matchlist_matches()
: display all recorded matchesget_top_scorer()
: return the top-scoring player (optional)get_highest_scoring_match()
: return the match with the highest total score (optional)
3. Programming Requirements
- Apply the 4 core OOP principles: Encapsulation, Inheritance, Polymorphism, Abstraction.
- Use
@property
decorators where appropriate (e.g., for calculating age). - Allow future expansion through subclassing (e.g.,
FootballMatch
,BasketballMatch
). - Use lists or dictionaries to manage collections of objects.
4. Sample Usage
# Create players
player1 = Player(1, "John", 10, "Striker", "2000-01-01", 8.5)
player2 = Player(2, "Mike", 7, "Midfielder", "1998-03-22", 7.0)
# Create team and add players
teamA = Team(1, "Lions", "Coach A")
teamA.add_player(player1)
teamA.add_player(player2)
# Create match
match = Match(1001, teamA, teamB, "2025-07-20", "National Stadium")
# Record a scoring event
event = ScoreEvent(12, teamA, player1, "goal", 1)
match.add_score_event(event)
# Output match result
print(match.get_score()) # (1, 0)
print(match.get_winner()) # Lions
5. Expected Output Format
Match: Lions vs Tigers
Date: 2025-07-20
Location: National Stadium
Score Events:
- 00:12: Lions - Goal by #10 John
- 00:45: Tigers - Goal by #7 Kim
- 00:89: Lions - Goal by #10 John
Final Score:
Lions 2 - 1 Tigers
Winner: Lions
If you need a UML diagram, full Python implementation, command-line UI, or teaching slides based on this spec — just say the word.