Question: I do I integrate the class Contestants into my original code. Here is the class Contestants code and then the original code that it needs
I do I integrate the class Contestants into my original code. Here is the class Contestants code and then the original code that it needs to go into. Here are the codes:
public class Contestant
public static string talentCodes SDMO; Singing, Dancing, Musical Instrument, Other
public static string talentStrings "Singing", "Dancing", "Musical Instrument", "Other" ;
public string Name get; set;
private string talentCode;
public string Talent
get return talent;
private string talent;
public void SetTalentCodestring code
if ArrayIndexOftalentCodes code.ToUpper
talentCode code.ToUpper;
talent talentStringsArrayIndexOftalentCodes code.ToUpper;
else
talentCode "I"; Invalid
talent "Invalid Talent";
Here is the original code:
using System;
using static System.Console;
using System.Globalization;
class GreenvilleRevenue
static void Main
const int ENTRANCEFEE ;
const int MINCONTESTANTS ;
const int MAXCONTESTANTS ;
int numThisYear;
int numLastYear;
int revenue;
string names new stringMAXCONTESTANTS;
char talents new charMAXCONTESTANTS;
char talentCodes SDMO;
string talentCodesStrings Singing "Dancing", "Musical instrument", "Other";
int counts ;
numLastYear getContestantNumberlast MINCONTESTANTS, MAXCONTESTANTS;
numThisYear getContestantNumberthis MINCONTESTANTS, MAXCONTESTANTS;
revenue numThisYear ENTRANCEFEE;
WriteLineLast year's competition had contestants, and this year's has contestants",
numLastYear, numThisYear;
WriteLineRevenue expected this year is revenue.ToStringC;
displayRelationshipnumThisYear numLastYear;
getContestantDatanumThisYear names, talents, talentCodes, talentCodesStrings, counts;
getListsnumThisYear talentCodes, talentCodesStrings, names, talents, counts;
public static int getContestantNumberstring when, int min, int max
string entryString;
int num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
whilenum min num max
ifint.TryParseentryString out num
WriteLineFormat invalid";
num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
else
ifnum min num max
WriteLineNumber must be between and min, max;
num max ;
WriteEnter number of contestants year when;
entryString ReadLine;
return num;
public static void displayRelationshipint numThisYear, int numLastYear
ifnumThisYear numLastYear
WriteLineThe competition is more than twice as big this year!";
else
ifnumThisYear numLastYear
WriteLineThe competition is bigger than ever!";
else
ifnumThisYear numLastYear
WriteLineA tighter race this year! Come out and cast your vote!";
public static void getContestantDataint numThisYear, string names, char talents, char talentCodes, string talentCodesStrings, int counts
int x ;
bool isValid;
whilex numThisYear
WriteEnter contestant name ;
namesx ReadLine;
WriteLineTalent codes are:";
forint y ; y talentCodes.Length; y
WriteLine talentCodesy talentCodesStringsy;
Write Enter talent code ;
isValid false;
whileisValid
ifchar.TryParseReadLine out talentsx
WriteLineInvalid format entry must be a single character";
else
forint z ; z talentCodes.Length; z
iftalentsx talentCodesz
isValid true;
countsz;
ifisValid
WriteLineThat is not a valid code";
Write Enter talent code ;
x;
public static void getListsint numThisYear, char talentCodes, string talentCodesStrings, string names, char talents, int counts
int x;
char QUIT Z;
char option;
bool isValid;
int pos ;
bool found;
WriteLine
The types of talent are:";
forx ; x counts.Length; x
WriteLine talentCodesStringsx countsx;
Write
Enter a talent type or to quit QUIT;
isValid false;
whileisValid
ifchar.TryParseReadLine out option
isValid false;
WriteLineInvalid format entry must be a single character";
Write
Enter a talent type or to quit QUIT;
else
ifoption QUIT
isValid true;
else
forint z ; z talentCodes.Length; z
ifoption talentCodesz
isValid true;
pos z;
ifisValid
WriteLine is not a valid code", option;
Write
Enter a talent type or to quit QUIT;
else
WriteLine
Contestants with talent are:", talentCodesStringspos;
found false;
forx ; x numThisYear; x
iftalentsx option
WriteLinenamesx;
found true;
iffound
WriteLineNo contestants had talent talentCodesStringspos;
isValid false;
Write
Enter a talent type or to quit QUIT;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
