SlideShare a Scribd company logo
1 of 7
Assignment #8
Objectives
1. To learn how to design and implement functions for program
development
2. To reinforce how to use pass by value and pass by reference
variables
3. To learn how to use structures
Problem: Dragon Collecting (dragondex.c)
Movies about dragons and dragon training were very popular
this summer. Your friend has not stopped talking about how
awesome dragons are and how cool it would be to train them.
After completing your dragon training simulator, your friend is
ready to graduate to having a team of dragons.
You are now building a program that will store a collection of
dragons for your friend’s team. Your friend will need to be able
to do the following:
1) Add a dragon to his team
2) Remove a dragon from his team
3) Search for a particular dragon
4) List all of the dragons of a particular color on the team
To make the testing of the program easier, your program will
read in all of its input from a file called “dragon.txt”. Your
friend’s team of dragon cannot exceed 1000 dragons.
Header Specification
To facilitate grading, include in your header comment which
portions of the assignment you have completed. You must
complete all options in order to earn full credit. Your choices
are as follows:
(1) Adding dragons only
(2) Adding and removing dragons only
(3) Adding, removing, and searching dragons only
(4) All options implemented: adding, removing, searching, and
listing dragons
If your comment is accurate, meaning that you pass the
appropriate tests cases corresponding to your choice, you'll earn
10 points. If your comment is roughly accurate, meaning that
you sincerely attempted the items you listed, and most of them
work minus a tiny bug, then you'll get 5 of these points. If your
comment isn't accurate to a reasonable degree, you'll get 0 of
these points.
The reason this is here is because it's very important to
communicate to others accurately what you've accomplished and
what is left to accomplish. This sort of honesty and ability to
appraise your own work is a critical skill in a job.
Input Specification (dragon.txt)
The first line of the file will contain a single positive integer
representing the number of updates to the dragon team. (Note:
We assume that at the beginning of the program, the team has
no dragons on it.) Each following line will have directions for a
single update to the dragon team. The formats for these lines are
as follows:
The very first value on each of these lines will be a string from
the following subset: {ADD, REMOVE, SEARCH, LIST}. This
string indicates which operation (corresponding to the list in the
problem statement) is being designated.
If the operation is to add a dragon (ADD), then the line will
contain the following information after ADD, separated by
spaces:
NAME COLOR
The name and color of the dragon will be strings that contain
only alphabetic letters and underscores. None of these strings
will exceed 39 characters. No dragon will share a name with
another dragon, though there may be multiple dragons of the
same color.
If the operation is to remove a dragon (REMOVE), then the line
will only contain the exact name of the dragon after REMOVE.
If the operation is to search for a dragon (SEARCH), then the
line will only contain the exact name of the dragon that is being
searched for.
If the operation is to list all of the dragons by a particular color
(LIST), then the line will only contain the desired color after
LIST.
Output Specification
All output should go to the screen. Separate the output for each
command with one blank line. Here is the format for output for
each command:
For adding a dragon, simply write out a statement of the form:
X the Y dragon has been added to the team.
For removing a dragon, simply write out a statement of the
form:
X the Y dragon has been removed from the team.
For both of these, X represents the name of the dragon and Y
represents the dragon’s color. You may assume that remove
operations in the input file will always be valid. Thus, if a
remove is ever requested, the dragon in question is guaranteed
to be on the team.
For searching for a dragon, output one of two statements,
depending on whether or not the designated dragon was found
on the team:
X the dragon is currently on the team.
X the dragon is NOT currently on the team.
For searching for all the dragons of a particular color, output a
single line of the form:
Y dragons:
Y represents the color requested. Each following line should list
the name of one dragon of that color on the team. List each
dragon exactly once.
Implementation Restrictions
You must use the following constants:
#define MAX_LENGTH 40
#define MAX_TEAM 1000
You must use the following structures to store information:
struct dragon {
char name[MAX_LENGTH];
char color[MAX_LENGTH];
};
struct collection {
struct dragon team[MAX_TEAM];
int num_dragons;
};
It is not sufficient to simply have the structures in your
program, you must use them store information and process
operations for the dragon team.
Though function prototypes will not be provided, it is expected
that you follow good programming design and create several
functions with well-specified tasks related to the solution of
this problem. Make sure to pay very careful attention to
parameter passing.
Hints
Use pass by reference parameters for your functions. This will
ensure that any change made to the dragon team in the function
is reflected in main. Inside the function, remember to access the
components using the -> syntax for structures.
Use the prewritten string functions when dealing with strings:
· use strcpy whenever you want to copy the contents of one
string into another, instead of the equals sign.
· use strcmp to determine which operation is being requested.
Whenever you add a dragon to the team, make sure you add it to
the first open slot on the team.
Whenever you remove a dragon from the team, make sure you
copy the dragon in the last spot on the team into the vacated
spot. For example, if the dragon to be removed is in index 3 and
the number of dragons on the team before removal is 7, then the
dragon in index 6 (the last filled index) should be copied into
the dragon spot in index 3. Subsequently, the number of dragons
on the team should be updated to 6.
Sample Input File (library.txt)
12
ADD TOOTHFUL BLACK
ADD SPITFIRE RED
SEARCH FURY
ADD FURY RED
ADD ICICLE BLUE
ADD NIGHTWING BLACK
LIST BLACK
REMOVE SPITFIRE
ADD STARFALL BLUE
LIST RED
LIST GREEN
LIST BLUE
Sample Output (corresponding to input file)
TOOTHFUL the BLACK dragon has been added to the team.
SPITFIRE the RED dragon has been added to the team.
FURY the dragon is NOT currently on the team.
FURY the RED dragon has been added to the team.
ICICLE the BLUE dragon has been added to the team.
NIGHTWING the BLACK dragon has been added to the team.
BLACK dragons:
TOOTHFUL
NIGHTWING
SPITFIRE the RED dragon has been removed from the team.
STARFALL the BLUE dragon has been added to the team.
RED dragons:
FURY
GREEN dragons:
BLUE dragons:
ICICLE
STARFALL
Deliverables
One source file: dragondex.c for your solution to the given
problem submitted over WebCourses.
Restrictions
Although you may use other compilers, your program must
compile and run using Code::Blocks. Your program should
include a header comment with the following information: your
name, course number, section number, assignment title, and
date. Also, make sure you include comments throughout your
code describing the major steps in solving the problem.
Grading Details
Your programs will be graded upon the following criteria:
1) Your correctness
2) Your programming style and use of white space. Even if you
have a plan and your program works perfectly, if your
programming style is poor or your use of white space is poor,
you could get 10% or 15% deducted from your grade.
3) Compatibility – You must submit C source files that can be
compiled and executed in a standard C Development
Environment. If your program does not compile, you will get a
sizable deduction from your grade.

More Related Content

Similar to Assignment #8Objectives1. To learn how to design and impleme.docx

Questions4
Questions4Questions4
Questions4hccit
 
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docxLab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docxsmile790243
 
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdfCode In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdfaishwaryaequipment
 
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxFaculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxmydrynan
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotesSowri Rajan
 
Hasktut
HasktutHasktut
Hasktutkv33
 
Bc0038– data structure using c
Bc0038– data structure using cBc0038– data structure using c
Bc0038– data structure using chayerpa
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make YASHU40
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in RAndrew Lowe
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfKabilaArun
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfattalurilalitha
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonCP-Union
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2dataJohnson Ubah
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...Maulik Borsaniya
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaManoj Kumar kothagulla
 
Introduction to scala for a c programmer
Introduction to scala for a c programmerIntroduction to scala for a c programmer
Introduction to scala for a c programmerGirish Kumar A L
 

Similar to Assignment #8Objectives1. To learn how to design and impleme.docx (20)

Questions4
Questions4Questions4
Questions4
 
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docxLab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
 
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdfCode In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
 
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docxFaculty of ScienceDepartment of ComputingFinal Examinati.docx
Faculty of ScienceDepartment of ComputingFinal Examinati.docx
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
Hasktut
HasktutHasktut
Hasktut
 
Bc0038– data structure using c
Bc0038– data structure using cBc0038– data structure using c
Bc0038– data structure using c
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in R
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
C basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kellaC basic questions&ansrs by shiva kumar kella
C basic questions&ansrs by shiva kumar kella
 
Introduction to scala for a c programmer
Introduction to scala for a c programmerIntroduction to scala for a c programmer
Introduction to scala for a c programmer
 

More from fredharris32

A report writingAt least 5 pagesTitle pageExecutive Su.docx
A report writingAt least 5 pagesTitle pageExecutive Su.docxA report writingAt least 5 pagesTitle pageExecutive Su.docx
A report writingAt least 5 pagesTitle pageExecutive Su.docxfredharris32
 
A reflection of how your life has changedevolved as a result of the.docx
A reflection of how your life has changedevolved as a result of the.docxA reflection of how your life has changedevolved as a result of the.docx
A reflection of how your life has changedevolved as a result of the.docxfredharris32
 
A Princeton University study argues that the preferences of average.docx
A Princeton University study argues that the preferences of average.docxA Princeton University study argues that the preferences of average.docx
A Princeton University study argues that the preferences of average.docxfredharris32
 
A rapidly growing small firm does not have access to sufficient exte.docx
A rapidly growing small firm does not have access to sufficient exte.docxA rapidly growing small firm does not have access to sufficient exte.docx
A rapidly growing small firm does not have access to sufficient exte.docxfredharris32
 
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docx
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docxA psychiatrist bills for 10 hours of psychotherapy and medication ch.docx
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docxfredharris32
 
A project to put on a major international sporting competition has t.docx
A project to put on a major international sporting competition has t.docxA project to put on a major international sporting competition has t.docx
A project to put on a major international sporting competition has t.docxfredharris32
 
A professional services company wants to globalize by offering s.docx
A professional services company wants to globalize by offering s.docxA professional services company wants to globalize by offering s.docx
A professional services company wants to globalize by offering s.docxfredharris32
 
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docx
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docxA presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docx
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docxfredharris32
 
a presentatiion on how the over dependence of IOT AI and robotics di.docx
a presentatiion on how the over dependence of IOT AI and robotics di.docxa presentatiion on how the over dependence of IOT AI and robotics di.docx
a presentatiion on how the over dependence of IOT AI and robotics di.docxfredharris32
 
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docx
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docxA P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docx
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docxfredharris32
 
A nursing care plan (NCP) is a formal process that includes .docx
A nursing care plan (NCP) is a formal process that includes .docxA nursing care plan (NCP) is a formal process that includes .docx
A nursing care plan (NCP) is a formal process that includes .docxfredharris32
 
A nurse educator is preparing an orientation on culture and the wo.docx
A nurse educator is preparing an orientation on culture and the wo.docxA nurse educator is preparing an orientation on culture and the wo.docx
A nurse educator is preparing an orientation on culture and the wo.docxfredharris32
 
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docx
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docxA NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docx
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docxfredharris32
 
A Look at the Marburg Fever OutbreaksThis week we will exami.docx
A Look at the Marburg Fever OutbreaksThis week we will exami.docxA Look at the Marburg Fever OutbreaksThis week we will exami.docx
A Look at the Marburg Fever OutbreaksThis week we will exami.docxfredharris32
 
A network consisting of M cities and M-1 roads connecting them is gi.docx
A network consisting of M cities and M-1 roads connecting them is gi.docxA network consisting of M cities and M-1 roads connecting them is gi.docx
A network consisting of M cities and M-1 roads connecting them is gi.docxfredharris32
 
A minimum 20-page (not including cover page, abstract, table of cont.docx
A minimum 20-page (not including cover page, abstract, table of cont.docxA minimum 20-page (not including cover page, abstract, table of cont.docx
A minimum 20-page (not including cover page, abstract, table of cont.docxfredharris32
 
A major component of being a teacher is the collaboration with t.docx
A major component of being a teacher is the collaboration with t.docxA major component of being a teacher is the collaboration with t.docx
A major component of being a teacher is the collaboration with t.docxfredharris32
 
a mad professor slips a secret tablet in your food that makes you gr.docx
a mad professor slips a secret tablet in your food that makes you gr.docxa mad professor slips a secret tablet in your food that makes you gr.docx
a mad professor slips a secret tablet in your food that makes you gr.docxfredharris32
 
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docx
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docxA New Mindset for   Leading Change [WLO 1][CLO 6]Through.docx
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docxfredharris32
 
A N A M E R I C A N H I S T O R YG I V E M EL I B.docx
A N  A M E R I C A N  H I S T O R YG I V E  M EL I B.docxA N  A M E R I C A N  H I S T O R YG I V E  M EL I B.docx
A N A M E R I C A N H I S T O R YG I V E M EL I B.docxfredharris32
 

More from fredharris32 (20)

A report writingAt least 5 pagesTitle pageExecutive Su.docx
A report writingAt least 5 pagesTitle pageExecutive Su.docxA report writingAt least 5 pagesTitle pageExecutive Su.docx
A report writingAt least 5 pagesTitle pageExecutive Su.docx
 
A reflection of how your life has changedevolved as a result of the.docx
A reflection of how your life has changedevolved as a result of the.docxA reflection of how your life has changedevolved as a result of the.docx
A reflection of how your life has changedevolved as a result of the.docx
 
A Princeton University study argues that the preferences of average.docx
A Princeton University study argues that the preferences of average.docxA Princeton University study argues that the preferences of average.docx
A Princeton University study argues that the preferences of average.docx
 
A rapidly growing small firm does not have access to sufficient exte.docx
A rapidly growing small firm does not have access to sufficient exte.docxA rapidly growing small firm does not have access to sufficient exte.docx
A rapidly growing small firm does not have access to sufficient exte.docx
 
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docx
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docxA psychiatrist bills for 10 hours of psychotherapy and medication ch.docx
A psychiatrist bills for 10 hours of psychotherapy and medication ch.docx
 
A project to put on a major international sporting competition has t.docx
A project to put on a major international sporting competition has t.docxA project to put on a major international sporting competition has t.docx
A project to put on a major international sporting competition has t.docx
 
A professional services company wants to globalize by offering s.docx
A professional services company wants to globalize by offering s.docxA professional services company wants to globalize by offering s.docx
A professional services company wants to globalize by offering s.docx
 
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docx
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docxA presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docx
A presentation( PowerPoint) on the novel, Disgrace by J . M. Coetzee.docx
 
a presentatiion on how the over dependence of IOT AI and robotics di.docx
a presentatiion on how the over dependence of IOT AI and robotics di.docxa presentatiion on how the over dependence of IOT AI and robotics di.docx
a presentatiion on how the over dependence of IOT AI and robotics di.docx
 
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docx
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docxA P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docx
A P P L I C A T I O N S A N D I M P L E M E N T A T I O Nh.docx
 
A nursing care plan (NCP) is a formal process that includes .docx
A nursing care plan (NCP) is a formal process that includes .docxA nursing care plan (NCP) is a formal process that includes .docx
A nursing care plan (NCP) is a formal process that includes .docx
 
A nurse educator is preparing an orientation on culture and the wo.docx
A nurse educator is preparing an orientation on culture and the wo.docxA nurse educator is preparing an orientation on culture and the wo.docx
A nurse educator is preparing an orientation on culture and the wo.docx
 
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docx
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docxA NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docx
A NOVEL TEACHER EVALUATION MODEL 1 Branching Paths A Nove.docx
 
A Look at the Marburg Fever OutbreaksThis week we will exami.docx
A Look at the Marburg Fever OutbreaksThis week we will exami.docxA Look at the Marburg Fever OutbreaksThis week we will exami.docx
A Look at the Marburg Fever OutbreaksThis week we will exami.docx
 
A network consisting of M cities and M-1 roads connecting them is gi.docx
A network consisting of M cities and M-1 roads connecting them is gi.docxA network consisting of M cities and M-1 roads connecting them is gi.docx
A network consisting of M cities and M-1 roads connecting them is gi.docx
 
A minimum 20-page (not including cover page, abstract, table of cont.docx
A minimum 20-page (not including cover page, abstract, table of cont.docxA minimum 20-page (not including cover page, abstract, table of cont.docx
A minimum 20-page (not including cover page, abstract, table of cont.docx
 
A major component of being a teacher is the collaboration with t.docx
A major component of being a teacher is the collaboration with t.docxA major component of being a teacher is the collaboration with t.docx
A major component of being a teacher is the collaboration with t.docx
 
a mad professor slips a secret tablet in your food that makes you gr.docx
a mad professor slips a secret tablet in your food that makes you gr.docxa mad professor slips a secret tablet in your food that makes you gr.docx
a mad professor slips a secret tablet in your food that makes you gr.docx
 
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docx
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docxA New Mindset for   Leading Change [WLO 1][CLO 6]Through.docx
A New Mindset for   Leading Change [WLO 1][CLO 6]Through.docx
 
A N A M E R I C A N H I S T O R YG I V E M EL I B.docx
A N  A M E R I C A N  H I S T O R YG I V E  M EL I B.docxA N  A M E R I C A N  H I S T O R YG I V E  M EL I B.docx
A N A M E R I C A N H I S T O R YG I V E M EL I B.docx
 

Recently uploaded

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Recently uploaded (20)

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

Assignment #8Objectives1. To learn how to design and impleme.docx

  • 1. Assignment #8 Objectives 1. To learn how to design and implement functions for program development 2. To reinforce how to use pass by value and pass by reference variables 3. To learn how to use structures Problem: Dragon Collecting (dragondex.c) Movies about dragons and dragon training were very popular this summer. Your friend has not stopped talking about how awesome dragons are and how cool it would be to train them. After completing your dragon training simulator, your friend is ready to graduate to having a team of dragons. You are now building a program that will store a collection of dragons for your friend’s team. Your friend will need to be able to do the following: 1) Add a dragon to his team 2) Remove a dragon from his team 3) Search for a particular dragon 4) List all of the dragons of a particular color on the team To make the testing of the program easier, your program will read in all of its input from a file called “dragon.txt”. Your friend’s team of dragon cannot exceed 1000 dragons. Header Specification To facilitate grading, include in your header comment which portions of the assignment you have completed. You must complete all options in order to earn full credit. Your choices are as follows:
  • 2. (1) Adding dragons only (2) Adding and removing dragons only (3) Adding, removing, and searching dragons only (4) All options implemented: adding, removing, searching, and listing dragons If your comment is accurate, meaning that you pass the appropriate tests cases corresponding to your choice, you'll earn 10 points. If your comment is roughly accurate, meaning that you sincerely attempted the items you listed, and most of them work minus a tiny bug, then you'll get 5 of these points. If your comment isn't accurate to a reasonable degree, you'll get 0 of these points. The reason this is here is because it's very important to communicate to others accurately what you've accomplished and what is left to accomplish. This sort of honesty and ability to appraise your own work is a critical skill in a job. Input Specification (dragon.txt) The first line of the file will contain a single positive integer representing the number of updates to the dragon team. (Note: We assume that at the beginning of the program, the team has no dragons on it.) Each following line will have directions for a single update to the dragon team. The formats for these lines are as follows: The very first value on each of these lines will be a string from the following subset: {ADD, REMOVE, SEARCH, LIST}. This string indicates which operation (corresponding to the list in the problem statement) is being designated. If the operation is to add a dragon (ADD), then the line will contain the following information after ADD, separated by spaces:
  • 3. NAME COLOR The name and color of the dragon will be strings that contain only alphabetic letters and underscores. None of these strings will exceed 39 characters. No dragon will share a name with another dragon, though there may be multiple dragons of the same color. If the operation is to remove a dragon (REMOVE), then the line will only contain the exact name of the dragon after REMOVE. If the operation is to search for a dragon (SEARCH), then the line will only contain the exact name of the dragon that is being searched for. If the operation is to list all of the dragons by a particular color (LIST), then the line will only contain the desired color after LIST. Output Specification All output should go to the screen. Separate the output for each command with one blank line. Here is the format for output for each command: For adding a dragon, simply write out a statement of the form: X the Y dragon has been added to the team. For removing a dragon, simply write out a statement of the form: X the Y dragon has been removed from the team. For both of these, X represents the name of the dragon and Y represents the dragon’s color. You may assume that remove operations in the input file will always be valid. Thus, if a remove is ever requested, the dragon in question is guaranteed
  • 4. to be on the team. For searching for a dragon, output one of two statements, depending on whether or not the designated dragon was found on the team: X the dragon is currently on the team. X the dragon is NOT currently on the team. For searching for all the dragons of a particular color, output a single line of the form: Y dragons: Y represents the color requested. Each following line should list the name of one dragon of that color on the team. List each dragon exactly once. Implementation Restrictions You must use the following constants: #define MAX_LENGTH 40 #define MAX_TEAM 1000 You must use the following structures to store information: struct dragon { char name[MAX_LENGTH]; char color[MAX_LENGTH]; }; struct collection { struct dragon team[MAX_TEAM]; int num_dragons; }; It is not sufficient to simply have the structures in your program, you must use them store information and process operations for the dragon team. Though function prototypes will not be provided, it is expected
  • 5. that you follow good programming design and create several functions with well-specified tasks related to the solution of this problem. Make sure to pay very careful attention to parameter passing. Hints Use pass by reference parameters for your functions. This will ensure that any change made to the dragon team in the function is reflected in main. Inside the function, remember to access the components using the -> syntax for structures. Use the prewritten string functions when dealing with strings: · use strcpy whenever you want to copy the contents of one string into another, instead of the equals sign. · use strcmp to determine which operation is being requested. Whenever you add a dragon to the team, make sure you add it to the first open slot on the team. Whenever you remove a dragon from the team, make sure you copy the dragon in the last spot on the team into the vacated spot. For example, if the dragon to be removed is in index 3 and the number of dragons on the team before removal is 7, then the dragon in index 6 (the last filled index) should be copied into the dragon spot in index 3. Subsequently, the number of dragons on the team should be updated to 6. Sample Input File (library.txt) 12 ADD TOOTHFUL BLACK ADD SPITFIRE RED SEARCH FURY ADD FURY RED ADD ICICLE BLUE ADD NIGHTWING BLACK
  • 6. LIST BLACK REMOVE SPITFIRE ADD STARFALL BLUE LIST RED LIST GREEN LIST BLUE Sample Output (corresponding to input file) TOOTHFUL the BLACK dragon has been added to the team. SPITFIRE the RED dragon has been added to the team. FURY the dragon is NOT currently on the team. FURY the RED dragon has been added to the team. ICICLE the BLUE dragon has been added to the team. NIGHTWING the BLACK dragon has been added to the team. BLACK dragons: TOOTHFUL NIGHTWING SPITFIRE the RED dragon has been removed from the team. STARFALL the BLUE dragon has been added to the team. RED dragons: FURY GREEN dragons: BLUE dragons: ICICLE STARFALL
  • 7. Deliverables One source file: dragondex.c for your solution to the given problem submitted over WebCourses. Restrictions Although you may use other compilers, your program must compile and run using Code::Blocks. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include comments throughout your code describing the major steps in solving the problem. Grading Details Your programs will be graded upon the following criteria: 1) Your correctness 2) Your programming style and use of white space. Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor, you could get 10% or 15% deducted from your grade. 3) Compatibility – You must submit C source files that can be compiled and executed in a standard C Development Environment. If your program does not compile, you will get a sizable deduction from your grade.