首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CS 215编程讲解、辅导program程序、c/c++设计程序辅导 讲解数据库SQL|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
CS 215 – Winter 2019
Project 3/4
Learning Objectives:
- Implementation of a program using Object Oriented Design.
- Implementation of lists using Dynamically-Allocated Linked Lists.
General Description:
You are to write a program that implements score keeping for a league of sports teams. The league
consists of a list of teams that are members of the league, and a list of games/matches.
Team data and initial game data are read from text files. Using menu options, the user may view various
parts of the data, and may add new games to the data. The game data is then written to a text file on
exit from the program.
The program presents the user with the menu as
shown here, starting with a logo that contains the
program name and the name of the programmer.
The menu option entered by the user is validated
until a valid menu option is entered. Only the first
character of the user’s input is recognized, and that
character is treated as not case sensitive. After
performance of a valid option, the menu repeats
until the exit option is selected.
List all teams:
A list of all teams read from the input file is printed
using the format shown in the example. The header
line includes the total number of teams in
parenthesis. Field widths include:
- Team Id 4
- Team Name 25
- Coach 20
with two spaces between columns. No system pause
is needed after the list is printed.
List all games:
A list of all games read from the input file and entered by the
user is printed using the format shown in the example. The
header line includes the total number of teams in
parenthesis. The field widths include:
- Date 10 (left justified)
- Team Ids 4 (left justified)
- Scores 3 (right justified)
with two spaces between columns. Note that the winning
team is listed first on each line. After the last game is printed,
a blank line is followed by a system pause.
2
Query Team:
First, the list of teams is printed, exactly as in print all teams above.
Next, the user is asked to enter the Team Id of the selected team. The user’s input is validated to be a
valid Team Id, repeating until a valid
value is entered.
A report of the selected team is printed
as shown in the example. It includes
the number of games won and lost by
the team, based on counts taken from
the game data.
Finally, the game list is printed,
formatted exactly as described above
for print all teams. Note that both
games lost (team data in the right
columns) and games won (team data in
the center columns) are printed.
Add Game:
First, the list of all teams is printed exactly as described above for print all teams.
The user is then asked to enter the Team Id for the first team. This is validated/repeated exactly as
described for Query Team. The Team Id
for the second team is entered/validated.
Next, the points for the two teams and
the date of the game are entered. There is
no validation for these three values, and it
is assumed the user will enter integers for
scores, and a string with no spaces in the
correct date format for the date.
Once all data is entered, and the game data added to the internal list, the program prints “Game
added”. Note the program may have to “swap” team 1 with team 2 when adding the game, depending
on the higher score (since the winning team should be stored as team 1).
Exit:
The program should write the current game data to an
output file called “games2.txt”, then do a system
pause before ending the program.
3
Detailed Design:
The program should be designed and implemented using Object Oriented Programming. All lists should
be implemented as Dynamically-Allocated Linked Lists.
main program:
Write a free function called doAbort() that is given an error message (string). It prints the error message
on the screen, followed by a newline; does a system pause; and ends the program with exit(1); For any
.cpp in the project that needs to invoke this free function, place its prototype at the top of the .cpp file.
The main program should declare a league class and invoke the go() method. This should be followed by
the standard system pause and return 0;
The classes consist of the following:
team
A team consists of the following data:
- Team Id (assumed to be length 4 or less with no spaces)
- Name (assumed to be length 25 or less and may have spaces)
- Coach (assumed to be length 20 or less and may have spaces)
- next (pointer to the next team object in a linked list of teams)
Standard set and get methods should be coded for the Team Id, Name and Coach (probably not needed
for the next pointer, but those may be added if needed).
Write a standard constructor (pointers are usually set to NULL in constructors).
You may declare the team list class to be a friend, but no other classes or free functions should be
declared as friends.
team list
The team list is a dynamic linked list of team objects. The only data needed is a head pointer for the
linked list (optional: a tail pointer). The constructor should set the head (and tail) to NULL.
The methods that should be implemented include:
addTeam: given a new team object
Dynamically allocates a new team object and copies the data from the given object into the
dynamic object. It should then add the new object to the front (head) of the linked list.
4
readData:
Reads data from a file called “teams.txt” and adds them to the linked list.
The format of the input file is, for each team:
- first line: the Team Id, a string with no spaces
- second line: the Team Name, a string with spaces
- third line: the Coach, a string with spaces
-
There is no “number of teams” nor a Sentinel value at the end of the data. Instead use the .eof()
method of an ifstream to detect end of file. Ex: while(!f.eof()) { … }
A sample input file is provided on the course website. Here is one with two teams:
UK
Kentucky Wildcats
Calipari
LOU
Louisville Cardinals
Job Open
printTeams:
Prints the team list report as described above, based on data currently in the linked list of
teams.
getTeamRef: given: a Team Id
returns: a pointer to a team, or NULL
Searches the current linked list for a team object that has a matching Team Id member. When
found, return the pointer to the team object found; otherwise, return NULL for “not found”.
getNumTeams: returns: the number of teams in the list.
Count and return the number of nodes in the list, which may be 0.
game: game objects will be part of a linked list (gameList) and will also point to objects in the Team List
A game consists of the following data for a game played between two teams:
- date a string assumed to be in YYYY/MM/DD format (length 10)
- points scored(2) points scored by team 1 and team 2
- team pointer (2) a pointer to a team in the teamList list for team 1 and team 2
- next a pointer to a game, the next game in the list or NULL
The class may make class gameList a friend, but no other classes or functions.
Constructor: standard constructor initializing all members of the object.
set: one set method given a date, two team pointers, and two scores.
alternative: one set method for each member (except next)
gets: one get for each member, except next.
5
gameList: this is a Linked List of game objects, including a head and tail pointer.
data and constructor
head - a pointer to a game object, the first in the list
tail - a pointer to a game object, the last in the list
constructor – simply sets the two pointers to NULL.
addGame – given a game object.
- dynamically allocates a new game object
- copies the data members from the given object into the newly allocated object
- inserts the newly allocated object into the game list at the tail of the list.
readGames: - given a Team List Object.
This method reads game data from a file called “games.txt” (validate the file opens, and
close at the end) and creates the initial game list.
The format of the game input file is: each line contains data on one game in the following order:
DATE TEAM ID 1 POINTS FOR TEAM 1 TEAM ID2 POINTS FOR TEAM 2
There is no “number of games” at the top of file, and there is no sentinel value/record at the
end of the file. Use eof() to detect the end of file. A sample data file is provided on the course
website.
The method should read data into a local game object. It will have to “look up” a pointer to each
team using the Team List Object passed in. It should invoke addGame on the populated game
object to add a new game to the list.
This function invokes the global free function (declared in main() and prototyped in this .cpp file)
abort() when:
- the file fails to open
"gameList::readGames: unable to open games.txt”
- the Team Id read is not found in the given Team List for either team:
"gameList::read: invalid team id 1/2 = " + teamIdReadFromFile
getNumGames – counts and returns the number of games in the entire list.
getNumWins – given a pointer to a team object, searches the list and counts/returns the number of
games won by the team pointed to by the given pointer.
getNumLosses – given a pointer to a team object, searches the list and counts/returns the number of
games lost by the team pointed to by the given pointer.
6
printGames – given a pointer to a team object
- when the given pointer is NULL, prints all games in the list.
(See List all games example above).
- when the given pointer is NOT NULL, prints all games in the list where the given pointer points
to the same team object as “team pointer 1” or “team pointer 2” in the list.
(See Query Team example above).
- Print a “header” as shown in the examples above, including the number of teams in a dashed
line for the first line (invoke getNumGames()). Put two blanks between each column. Assume
the max lengths on the data values are:
o date: 10
o points: 3
o team Id 4
writeGames –
Writes the current game data to a text file called “games2.txt”, in the same format as the input
file described in readGames above. The method should use the two team pointers for each
game to retrieve the Team Id for each.
league: this represents our whole application. Main simply declares a league object and invokes its go().
Most of the methods have been written for you (posted on the course website). Similar to your lab 8,
complete the methods where there are // TO DO: comment tags in the code.
All methods are private except go()!
Data and constructors
- a team list object
- a game list object
- constructor: since both members have their own constructors, a constructor is not needed.
askTeamId – given: a (string) prompt that is assumed to be like “Enter team id …”
returns: a pointer to the team found.
This method prints the prompt and allows the user to enter a Team Id (assume no spaces). It
searches the Team List for the team Id entered. When found, it returns the team Id pointer. When
not found, it repeats the question (prompt) until the user enters a valid team Id. See Query Team in
the specifications above.
addGame –
This method prints the team list, invokes askTeamId() twice to get the team pointers for two teams,
asks for the points for the two teams and the date of the game. It populates a local game object
then invokes addGame in the game list to add a new game to the list.
7
queryTeam –
This method first prints the team list. It invokes askTeamId to get a pointer to the team to look up. It
uses the get() methods from the team class to print the data from the found team object. Finally, it
prints all games for the team by invoking printGames() giving it the found team pointer. See Query
Team above for the format of the output.
getMenuOption – returns the user’s selected menu option. This is written for you.
go()
This is the “main” of the application. It starts by invoking the reads in both the team list and game
list objects. This is followed by the main menu control loop for the application.
Submission:
zip the following files into a .zip file, and submit the .zip in Canvas:
- game.h, game.cpp
- gameList.h, gameList.cpp
- team.h, team.cpp
- teamList.h, teamList.cpp
- league.h, league.cpp
- proj3/main.cpp
There is no need to include data files (.txt)
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!