0% found this document useful (0 votes)
44 views7 pages

project的副本

Uploaded by

benjaminxin11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views7 pages

project的副本

Uploaded by

benjaminxin11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CS 172

Individual Project
A Client-Server Application for
Managing Sports’ Events

In this project, you are expected to build a (simplified) management system for sports events.
The system you will build must be a client-server application, as introduced in Chapter 11:
you can actually re-use many elements that were described there, including (but not limited
to) the communication protocol that was defined.
The client(s) will send requests regarding the creation and manipulation of sports, teams,
and matches, which should be handled by the server. This information should be saved on
a database on the handled by the server application.
All the interactions between the user and the application should be handled by the client.
For instance, the client must ask the user about the name of a team and all its details and
send them to the server. The server cannot interact with the user.
On the other hand, the server will receive the requests and the necessary data from the client
and should respond accordingly. Moreover, all the database manipulation should happen on
the server, and the client cannot interact with the database.
You must respect and use all the names of classes, functions, methods, and so on precisely as
they are written in this document. You must also follow exactly the same interaction mode
as defined. If not, you may not get the grade corresponding to the functionalities affected.
The solution you implement should be thoroughly tested, but your submission must be
submitted with no data so that we can immediately test its entire functionality.
Note that we will use software to detect similarities among all submissions. You may be
selected to explain the code you submitted before your grade in this project is released.

1 The Client
The client must be able to send different types of requests, according to the user requests,
together with the necessary data in each case (please check the server section for details):

1
1. ADD_SPORT, to create a new sport;

2. LIST_SPORTS, to list all sports;

3. ADD_TEAM, to create a new team;


For this operation, the client must show all existing sports with a number, so the user
can choose just by typing a number (see the example and the slides from Chapter 12).

4. LIST_TEAMS, to list all teams;

5. ADD_MATCH, to create a new match between two teams;


For this operation, the client must show all existing teams with a number, so the user
can choose the home team and the other team just by typing a number for each.

6. LIST_MATCHES, to list all matches;

7. SHUTDOWN, for shutting down the server and closing the client.

Note that all the interaction with the user must be done by the client. Penalties will be
applied if the client accesses the database directly.
An example of a possible interaction with a client can be seen in Section 3.
You can use the Console.py file provided with Chapter 11’s code to implement the interac-
tion with the user (although it’s not mandatory).

2 The server
The server must rely on a DBM database to manage the sports, teams, and matches, and
serve the requests it receives.
In this case, you will need to have a DBM database for each kind of data of the project:
sports, teams, and matches.
All accesses to the database must be done on the server side. Penalties will be applied if the
client accesses the database directly.
Regarding the construction and manipulation of the database, you may rely on the materials
and the code provided in Chapter 12.
The Sport database saves the list of sports. A sport is represented just by its name, which
you can use as the key for the database. The value can be again the name of the sport.
For each team, we will save its number, name, sport, and location (similar to the previous
assignment). Use the number of the team as the key. This should be done in the Team
database. The sport value must act as a foreign key to the Sport’s table. That is, you
can only create a team with a sport that is already registered in the database. Note DBM

2
databases do not have the concept of foreign key. Thus, your code must ensure that the
sport used when creating a team already exists in the Sport database. A possible way to
ensure this is to show the user the existing sports when creating a new team, as can be seen
in the interaction example in Section 3. Thus, the user can chose an existing sport and your
code can use exactly the same value for the sport.
Each match will have a number as the key. The key should be generated by the server when
creating a new match. Since DBM databases only accept strings as keys, you must think
of a way to generate the key. Each match has also the two teams involved (note we will
assume all matches involve two teams), the date of the event (any date/time in this program
must follow this format: "YYYY-MM-DD HH:MM:SS" or "%Y-%m-%d %H:%M:%S" in Python),
the score of each team (an integer). Again, to represent the teams in a match you can use
their number. Note that each match must guarantee that only existing teams play (that is,
teams that already exist in the database). Note a team cannot play against itself (you must
guarantee this). Moreover, both teams in a match must play the same sport.
For the example of execution in Section 3, a possible content for the three databases would
be like this:
Sport database:

{’Baseball’: ’Baseball’, ’Football’: ’Football’}

Team database:

{’lzu1’: (’LZU Baseball Mega Team’, ’Baseball’, ’Lanzhou’),


’lzu2’: (’LZU Baseball Pro’, ’Baseball’, ’Yuzhong’),
’1134’: (’Football Masters’, ’Football’, ’Beijing’)}

Match database:

{’2’: (’lzu2’, ’lzu1’, datetime.datetime(2024, 5, 12, 10, 0), 0, 3)


’1’: (’lzu1’, ’lzu2’, datetime.datetime(2024, 5, 1, 12, 0), 0, 3)}

The server will then wait for requests and serve them until being shut down, and maintain
the information of all sports, teams, and matches consistently using the database.

3 Example of Interaction
Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: s
Name: Football
Sport Football successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: s

3
Name: Baseball
Sport Baseball successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: p
Sports:

Name: Baseball
Name: Football

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: t
Number: lzu1
Name: LZU Baseball Mega Team
Sports:
0: Baseball
1: Football

Number: 0
Location: Lanzhou
Team lzu1 successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: t
Number: lzu2
Name: LZU Baseball Pro
Sports:
0: Baseball
1: Football

Number: 0
Location: Yuzhong
Team lzu2 successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: e
TEAMS:

Team ’LZU Baseball Mega Team’, number ’lzu1’, plays Baseball at Lanzhou
Team ’LZU Baseball Pro’, number ’lzu2’, plays Baseball at Yuzhong

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: m
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
Choose the number of the home team: 0
you choose team: lzu1
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou

4
1: LZU Baseball Pro plays Baseball at Yuzhong
Choose the number of the other team: 0
you choose team: lzu1
A team cannot play agains itself. Please chose two different teams.
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
Choose the number of the home team: 0
you choose team: lzu1
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
Choose the number of the other team: 1
you choose team: lzu2
Date [%Y-%m-%d %H:%M:%S]: 2024-05-01 12:00:00
Home team score: 0
Other team score: 3
Match successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: a
MATCHES:

Baseball match on 2024-05-01 12:00:00:


Team ’LZU Baseball Mega Team’, number ’lzu1’, from Lanzhou: score 0
Team ’LZU Baseball Pro’, number ’lzu2’, from Yuzhong: score 3

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: t
Number: 1134
Name: Football Masters
Sports:
0: Baseball
1: Football

Number: 1
Location: Beijing
Team 1134 successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: m
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
2: Football Masters plays Football at Beijing
Choose the number of the home team: 0
you choose team: lzu1
Teams:

5
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
2: Football Masters plays Football at Beijing
Choose the number of the other team: 2
you choose team: 1134
Both teams must play the same sport. Please chose two teams that play the same sport.
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
2: Football Masters plays Football at Beijing
Choose the number of the home team: 1
you choose team: lzu2
Teams:
0: LZU Baseball Mega Team plays Baseball at Lanzhou
1: LZU Baseball Pro plays Baseball at Yuzhong
2: Football Masters plays Football at Beijing
Choose the number of the other team: 0
you choose team: lzu1
Date [%Y-%m-%d %H:%M:%S]: 2024-05-12 10:00:00
Home team score: 0
Other team score: 3
Match successfully created

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: a
MATCHES:

Baseball match on 2024-05-12 10:00:00:


Team ’LZU Baseball Pro’, number ’lzu2’, from Yuzhong: score 0
Team ’LZU Baseball Mega Team’, number ’lzu1’, from Lanzhou: score 3
Baseball match on 2024-05-01 12:00:00:
Team ’LZU Baseball Mega Team’, number ’lzu1’, from Lanzhou: score 0
Team ’LZU Baseball Pro’, number ’lzu2’, from Yuzhong: score 3

Add (S)port List S(p)orts Add (T)eam List T(e)ams Add (M)atch List M(a)tches (Q)uit [p]: q

4 Delivering
Note that all the interaction with the user must be done by the client. Penalties will be
applied if the client accesses the database directly.
You should also deliver a small report explaining your work. The report must have about
two pages (a few sentences less or more are acceptable). It must, at least:

• indicate the Python version you used during the development of your work;

6
• explain how you manage the keys for matches;

• explain how you include the sport in the request when creating a new team;

• explain how you prevent a team to play against itself;

• explain how you guarantee the two teams in a match play the same sport;

• explain how you get the information about a team when the user wants to list the
existing matches.

The report may also discuss other aspects of your work you find relevant.
Thus you should deliver only the following:

1. a file named server.py with the server of your program;

2. a file named client.py with the client of your program;

3. a PDF file with your report.

Note you don’t need to deliver the Console.py file even if you use it.
Your submission must according to Prof. Chao’s instructions.
You should deliver your work no later than June 23rd .

You might also like