首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导Program语言编程、data程序辅导、讲解C/C++编程 讲解SPSS|辅导Web开发
项目预算:
开发周期:
发布时间:
要求地区:
Due Sunday by 11:59pm Points 90 Submitting a file upload File Types tar
Available until Apr 16 at 11:59pm
Start Assignment
The Magician Spellbook Catalog
Problem Statement
The great magic university of Fakebills has been adding a lot of new spellbooks to their library lately.
The school administration has hired you to create a spellbook catalog program that will make
searching for spellbooks easier.
To simplify your task, the school has provided you with their spellbook information. These come in the
form of a text file that file contains a list of Fakebill's spellbooks and their included spells, all of the
information that your program will display.
Requirements
Command Line Argument:
When starting the program, the user will provide one command line argument. The command line
argument will be the name of the file that contains the information about spellbooks and included
spells. If the user does not provide the name of an existing file the program should print out an error
message and quit.
Sorting and Printing:
Once the program begins, the user should be prompted with a list of different ways to display the
spellbook and spell information. After the user has chosen an option, they should be asked if they
want the information printed to the screen or written to a file. If they choose to write to a file, they
should be prompted for a file name. If the file name already exists, the information should be
appended to the file. If the file name does not exist, a file should be created and the information
should be written to the file.
Available Options:
Sort spellbooks by number of pages: If the user picks this option the books must be sorted in
ascending order by number of pages. Once they are sorted, you should print/write to file the title
of the book and the number of pages it has.
Sort spells by effect: There are five types of spells: fire, bubble, memory_loss, death, poison. The
spells with bubble as the effect should be listed first, followed by memory_loss, fire, poison, and
death. Once they are sorted, you should print/write to file the spell name and its effect.
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 2/8
Sort by average success rate of spells: You must create a list of books sorted by the average
success rate of all the spells contained within the book. Once calculated, you should print/write to
file the title of each applicable book and the corresponding average success rate.
Quit: The program will exit.
Your program should continue sorting and printing/writing until the user chooses to quit. For the
sorting functionality, you can write your own sorting function, or consider using C++'s built in sort
function.
Required Structs:
The following structs are required in your program. They will help organize the information that will be
read in (or derived) from the files. You cannot modify, add, or take away any part of the struct.
The spellbook struct will be used to hold information from the spellbooks.txt file. This struct holds
information about a spellbook.
struct spellbook {
string title;
string author;
int num_pages;
int edition;
int num_spells;
float avg_success_rate;
struct spell* s;
};
The spell struct will also be used to read in information from the spellbooks.txt file. This struct holds
information about a spell. There are five options for effect: "fire", "poison", "bubble", "death", or
"memory_loss".
struct spell {
string name;
float success_rate;
string effect;
};
Required Functions:
You must implement the following functions in your program. You are not allowed to modify these
required function declarations in any way. Note: it is acceptable if you choose to add additional
functions (but you must still include the required functions). Note2: You must write the dynamic
memory allocation functionality yourself (i.e. no using vectors).
This function will dynamically allocate an array of spellbooks (of the requested size):
spellbook* create_spellbooks(int);
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 3/8
This function will fill a spellbook struct with information that is read in from spellbooks.txt. Hint:
“ifstream &” is a reference to a filestream object. You will need to create one and pass it into this
function to read from the spellbooks.txt file.
void get_spellbook_data(spellbook*, int, ifstream &);
This function will dynamically allocate an array of spells (of the requested size):
spell* create_spells(int);
This function will fill a spell struct with information that is read in from spellbooks.txt.
void get_spell_data(spell*, int, ifstream &);
You need to implement a function that will delete all the memory that was dynamically allocated. You
can choose the prototype. A possible example prototype includes the following:
void delete_spellbook_data(spellbook*, int);
Required Input File Format
Your program must accommodate the file formats as specified in this section. The spellbooks.txt file
has the following structure. The file information will be provided in sets (corresponding to each
spellbook). Each spellbook will be accompanied by a listing of the spells inside.
The spellbooks.txt file will have the following pattern, and an example can be found here
(https://canvas.oregonstate.edu/courses/1810763/files/85698756/download?download_frd=1) :
...
...
Example Operation
The following snippet of text shows an example implementation of the spellbook program. Note that
this example does not illustrate all required behavior. You must read this entire document to ensure
that you meet all of the program requirements.
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 4/8
$ ./catalog_prog spellbooks.txt
Which option would you like to choose?
Sort spellbooks by number of pages (Press 1):
Group spells by their effect (Press 2):
Sort spellbooks by average success rate (Press 3):
Quit (Press 4):
1
How would you like the information displayed?
Print to screen (Press 1)
Print to file (Press 2)
1
Spells_for_Dummies 303
Wacky_Witch_Handbook 1344
Necronomicon 1890
Forbidden_Tome 1938
Enchiridion 2090
The_Uses_of_Excalibur 3322
Charming_Charms 4460
Dorian 50000
Which option would you like to choose?
Sort spellbooks by number of pages (Press 1):
Group spells by their effect (Press 2):
Sort spellbooks by average success rate (Press 3):
Quit (Press 4):
3
How would you like the information displayed?
Print to screen (Press 1)
Print to file (Press 2)
1
erent.>
Wacky_Witch_Handbook 90.05
The_Uses_of_Excalibur 87.9
Forbidden_Tome 76.8
Necronomicon 72.34
Enchiridion 51.2
Dorian 48.64
Charming_Charms 37.8
Spells_for_Dummies 29.74
Which option would you like to choose?
Sort spellbooks by number of pages (Press 1):
Group spells by their effect (Press 2):
Sort spellbooks by average success rate (Press 3):
Quit (Press 4):
3
How would you like the information displayed?
Print to screen (Press 1)
Print to file (Press 2)
2
Please provide desired filename: success_rate_list.txt
Appended requested information to file.
Which option would you like to choose?
Sort spellbooks by number of pages (Press 1):
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 5/8
Group spells by their effect (Press 2):
Sort spellbooks by average success rate (Press 3):
Quit (Press 4):
2
How would you like the information displayed?
Print to screen (Press 1)
Print to file (Press 2)
1
bubble Bubble_Beam
bubble Exploratory_Maneuver
memory_loss Space_Out
memory_loss Preliminary_Black_out
memory_loss Wacky_Dreams
fire Blasto_Strike
fire Beginning_Blast
poison Cthulhu_Venom
death Deathrock
death Nightmare
death Deadly_Details
Which option would you like to choose?
Sort spellbooks by number of pages (Press 1):
Group spells by their effect (Press 2):
Sort spellbooks by average success rate (Press 3):
Quit (Press 4):
4
Programming Style/Comments
In your implementation, make sure that you include a program header. Also ensure that you use
proper indentation/spacing and include comments! Below is an example header to include. Make
sure you review the style guidelines
(https://canvas.oregonstate.edu/courses/1810763/files/85698962/download?download_frd=1) for this
class, and begin trying to follow them, i.e. don’t align everything on the left or put everything on one
line!
/******************************************************
** Program: catalog.cpp
** Author:
** Date:
** Description:
** Input:
** Output:
******************************************************/
When you compile your code, it is acceptable to use C++11 functionality in your program. In order to
support this, change your Makefile to include the proper flag.
For example, consider the following approach (note the inclusion of -std=c++11):
g++ -std=c++11 //other flags and parameters
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 6/8
Magician Spellbook Catalog
In order to submit your homework assignment, you must create a tarred archive that contains your .h,
.cpp, and Makefile files. This tar file will be submitted to Canvas. In order to create the tar file, use the
following command:
tar –cvf assign1.tar catalog.h catalog.cpp prog.cpp Makefile
Note that you are expected to modularize your code into a header file (.h), an implementation file
(.cpp), and a driver file (.cpp).
You do not need to submit the txt files. The TA’s will have their own for grading.
Grading
You are required to meet with a TA within two weeks of the assignment due date to demo and
receive a grade. You can schedule a demo with a TA online using the link provided on the TAs page.
You must use your OSU email to schedule (for FERPA reasons), or your appointment will be
cancelled.
Programming assignments that do not compile and run on the OSU ENGR servers will receive
a grade of zero, with no exceptions.
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 7/8
Criteria Ratings Pts
12 pts
10 pts
7 pts
6 pts
3 pts
3 pts
8 pts
4 pts
10 pts
6 pts
Program Header / Good indentation & Use of whitespace / Function Documentation
At a minimum, header should contain author's name (2pts) and a description of the
program. (2pts)
Is code easy for the TA to read? Conditional blocks of code should always be indented.
(5pts) Every function contains it's own initial block comment (or multiple lines of comments
prior to the function definition) that provides the reader with an explanation of the function's
purpose (5pts). -1 pt for each function that is missing a header (up to 5 point penalty).
All functions designed in a modular fashion / No global variables
-5 pts if there are any global variables used in the code. If functions are exceptionally long
(greater than about 20 lines of actual code) this is a potential indication of poor modularity.
-3 pts for each function that the TA concludes is poorly modularized.
Command Line Functionality
(3 pts) Program displays error and terminates gracefully if exactly one command line
parameter is not provided. (4pts) Program displays error and terminates gracefully if a nonexistent
file is specified.
Struct Usage
Code defines/uses the spellbook and spell structs exactly as specified. -3 pts for any
incorrect struct. It's okay if the code uses additional structs for other purposes.
Memory Cleanup
The Valgrind LEAK SUMMARY should report: "definitely lost: 0 bytes in 0 blocks". Each
"new" operation should have a corresponding delete operation.
Program Functionality
Program does not crash during testing (e.g. segmentation fault or similar abrupt halts)
Function prototypes
The following function prototypes are used (exactly as shown) and included in a .h file.
-2pts for any function that doesn't match.
spellbook * create_spellbooks(int); void get_spellbook_data(spellbook *, int, ifstream &);
spell * create_spells(int); void get_spell_data(spell *, int, ifstream &);
Correct TAR file
Program was submitted as a single TAR file that contains a working Makefile, an
application .cpp file, a header .h file, and an implementation .cpp file. Exact filenames do
not matter for the source code.
Dynamic arrays of structs
Dynamically allocated arrays of structs are used for the spellbooks.
Sort spellbooks by # pages
Program sorts and displays the spellbooks by number of pages.
2021/4/7 Program 1
https://canvas.oregonstate.edu/courses/1810763/assignments/8376088 8/8
Total Points: 90
Criteria Ratings Pts
6 pts
6 pts
6 pts
3 pts
Group spells by effect
Program displays spells in groups (bubble, memory_loss, fire, poison, death)
Display spellbooks (sorted by average success rate)
Program sorts spellbooks by the average success rate of the spells contained within. The
sorted list is displayed on screen.
Program writes requested output to file
The user is able to request that sorted output be redirected to a user-specified filename.
The correct information is appended to that particular file.
Program repeats
Program repeats until the user chooses to exit.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
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
软件定制开发网!