Homework

Homework Questions? Ask a Tutor for Answers ASAP

Ask an Expert,
Get an Answer ASAP!

Homework
This answer was rated:

You are going to code a program for a new golf league. The

You are going to code...
You are going to code a program for a new golf league.

The program will need to have the following:

1. An array of a variable number of golf teams (max 10).
2. Classes for the following:
a. A Team class containing team name, an array of 4 Player objects, and scoring rank of team.
b. A Player class containing first name, last name, handicap, score for last game and rank on team.
3. The program should offer the user the option of entering teams, player data and scores, and should calculate the scores and rankings for the teams and the league.
4. A sorted list of team information should be written to a file.
5. The user should be able to display all information


Your application must include the following:

Constructors
Delegate
Arrays
Abstract Class or Interface
Exception Handling
Static Data Members
Overloaded Operator or overridden method
MessageBox
Inheritance
Data Validation
File Input/Output
Value Added - something not listed above
Show More
Show Less
Ask Your Own Homework Question
Answered in 14 hours by:
5/17/2013
Angela--Mod
Category: Homework
Satisfied Customers: 8
Verified
Thank you for your patience, your business is very important to us, we are waiting on the professional with the right expertise to come online. Please let us know if you would like us to continue searching for a professional or if you would like us to close your question. Thank you for your understanding!
Ask Your Own Homework Question
Customer reply replied 4 years ago
Continue searching.
Thank you for your continued patience. I have marked your question high priority. You'll receive an email notification as soon as a professional replies. Best,

Angela
Ask Your Own Homework Question
Raj
Raj, Engineer
Category: Homework
Satisfied Customers: 1,290
Experience: 4 + Experiance in IT Industry
Verified
Hi there,

I can help you with the requirement.
By when do you need the solution?

Thank you
Ask Your Own Homework Question
Customer reply replied 4 years ago
If you can, i need it by 22 may. Thank You.
I will try my beat to finish this by then


Have a good day.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Here is sample:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Windows.Forms;

namespace ABCGolf
{
public partial class Form1 : Form, ITeam
{
// Global Variables for all of Form1 to access
string playeraddTeam = "";
List myTeams = new List(10);
string TeamText = "";
Team myteam = new Team();
private const int NOTFOUND = 99999;

public Form1()
{
InitializeComponent();
} // End Form1 constructor

private void btnClearTeam_Click(object sender, EventArgs e)
{
txtTeamName.Clear();
txtTeamRank.Clear();
} // End btnClearTeam_Click method

private void btnAddUpdateTeam_Click(object sender, EventArgs e)
{
try
{
if (txtTeamRank.Text != "" && txtTeamName.Text != "")
{
int teamrnk = Convert.ToInt16(txtTeamRank.Text);
Team myteam = new Team(txtTeamName.Text, teamrnk);
TeamText = txtTeamName.Text;
int theTruth = GetTheTruth(myTeams, myteam.TeamName);

if (theTruth == 1)
{
int Location = TeamGetIndex(myTeams, txtTeamName.Text);
myTeams.RemoveAt(Location);
cbUpdateTeam.Items.Remove(txtTeamName.Text);
}
if (myTeams.Count < 10)
{
myTeams.Add(myteam);
cbUpdateTeam.Items.Add(txtTeamName.Text);
cbViewTeam.Items.Add(txtTeamName.Text);
cbPlayerTeams.Items.Add(txtTeamName.Text);
}
else
{
MessageBox.Show("You must remove a team before entering a another team.");
}
txtTeamName.Clear();
txtTeamRank.Clear();
}
else
{
MessageBox.Show("You must enter a Value for both fields");
}
}
catch (Exception v)
{
MessageBox.Show(v.Message);
}
} // End btnAddUpdateTeam_Click method

public int TeamGetIndex(List myTeams, string p)
{
// Local Method Variables
int Index = 0;

foreach (Team I in myTeams)
{
if (I.TeamName == p)
{
return Index;
}
Index++;
}
// Team not found
Index = NOTFOUND;
return Index;
} // End TeamGetIndex method

public int PlayerGetIndex(List myPlayers, string p)
{
int Index = 0;
foreach (Golfer I in myPlayers)
{
if (I.LastName == p)
{
return Index;
}
Index++;
}
Index = NOTFOUND;
return Index;
} // End PlayerGetIndex method

private int GetTheTruth(List myTeams, string p)
{
foreach (Team I in myTeams)
{
if (I.TeamName == p)
{
return 1;
}
}
return 0;
} // End GetTheTruth method

private void cbUpdateTeam_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string name = cbUpdateTeam.SelectedItem.ToString();
Team theTeam = (from x in myTeams where x.TeamName == name select x).FirstOrDefault();

txtTeamName.Text = theTeam.TeamName;
TeamText = txtTeamName.Text;
txtTeamRank.Text = theTeam.TeamRank.ToString();
}
catch (Exception a)
{
MessageBox.Show(a.Message);
}
} // End cbUpdateTeam_SelectedIndexChanged method

private void btnDeleteTeam_Click(object sender, EventArgs e)
{
try
{
int Location2 = TeamGetIndex(myTeams, TeamText);
myTeams.RemoveAt(Location2);
cbUpdateTeam.Items.Remove(TeamText);
cbViewTeam.Items.Remove(TeamText);
cbPlayerTeams.Items.Remove(TeamText);
txtTeamName.Clear();
txtTeamRank.Clear();
cbUpdateTeam.Text = "";
}
catch (Exception m)
{
MessageBox.Show(m.Message);
}
} // End btnDeleteTeam_Click_1 method

private void cbViewTeam_SelectedIndexChanged(object sender, EventArgs e)
{
// Local Method Variables
Team gridteam = new Team();
try
{
gridteam = (from x in myTeams where x.TeamName == cbViewTeam.Text select x).FirstOrDefault();
if (gridteam.Players.Count != 0)
{
int counter = 0;
if (dataGridView1.Rows.Count > 1)
{
// Remove in decending order as rows are reindexed with each remove
dataGridView1.Rows.RemoveAt(3);
dataGridView1.Rows.RemoveAt(2);
dataGridView1.Rows.RemoveAt(1);
dataGridView1.Rows.RemoveAt(0);
}
foreach (Golfer i in gridteam.Players)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[counter].Cells[0].Value = i.FirstName;
dataGridView1.Rows[counter].Cells[1].Value = i.LastName;
dataGridView1.Rows[counter].Cells[2].Value = i.Handicap;
dataGridView1.Rows[counter].Cells[3].Value = i.RankOnTeam;
counter++;
}
}
else
{
MessageBox.Show("There are no Players entered on the Team you selected");
}
}
catch (Exception o)
{
MessageBox.Show(o.Message);
}
} // End cbViewTeam_SelectedIndexChanged method

private void cbTeams_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
lbMembers.Items.Clear();
playeraddTeam = cbPlayerTeams.Text;
Team LTeam = (from x in myTeams where x.TeamName == playeraddTeam select x).FirstOrDefault();
if (myTeams.Count != 0)
{
if (LTeam.Players != null)
{
foreach (Golfer i in LTeam.Players)
{
lbMembers.Items.Add(i.FirstName + " " + i.LastName);
}
}
}
else
{
MessageBox.Show("You have to Add a Team before you can add an Golfer");
}
}
catch (Exception l)
{
MessageBox.Show(l.Message);
}
} // End cbTeams_SelectedIndexChanged method

private void btnAddUpdate_Click(object sender, EventArgs e)
{
// Local Method Variables
Team myteam = new Team();
Golfer i = new Golfer();
try
{
if (cbPlayerTeams.Text != "")
{
i.FirstName = txtFName.Text;
i.LastName = txtLName.Text;
i.RankOnTeam = Convert.ToInt32(txtRank.Text);
i.LastGame = Convert.ToInt32(txtLastScore.Text);
i.Handicap = Convert.ToInt32(txtHandiCap.Text);
// GetTeam is an existing team in the list. At this point we don't need the myteam
Team GetTeam = (from t in myTeams where t.TeamName == cbPlayerTeams.Text select t).FirstOrDefault();
if (GetTeam.Players.Count < 4)
{
GetTeam.Players.Add(i);
lbMembers.Items.Add(i.FirstName + " " + i.LastName);
}
else
{
MessageBox.Show("You must remove a team member before entering a another player.");
}
/*************************************************************************/
txtFName.Clear();
txtLName.Clear();
txtRank.Clear();
txtLastScore.Clear();
txtHandiCap.Clear();
}
else
{
MessageBox.Show("You must Select a Team before entering a player");
}
}
catch (Exception u)
{
MessageBox.Show(u.Message);
}
} // End btnAddUpdate_Click method

private void LoadData_Click(object sender, EventArgs e)
{
myTeams = ReadXML();
PopulateComboboxes();
} // End LoadTeams_Click method

private void SaveData_Click(object sender, EventArgs e)
{
WriteXML(myTeams);
} // End SaveTeams_Click method

private void Exit_Click(object sender, EventArgs e)
{
this.Dispose();
} // End Exit_Click method

private void About_Click(object sender, EventArgs e)
{
AboutBox About = new AboutBox();
About.Show();
} // End LoadTeams_Click method

private void lbMembers_SelectedIndexChanged(object sender, EventArgs e)
{
// Local Method Variables
Golfer lbGolfer = new Golfer();
Team lbTeam = new Team();
try
{
lbTeam = (from x in myTeams where x.TeamName == cbPlayerTeams.Text select x).FirstOrDefault();
lbGolfer = (from i in lbTeam.Players where i.FirstName + " " + i.LastName == lbMembers.SelectedItem.ToString() select i).FirstOrDefault();//.Contains(lbMembers.SelectedItem.ToString()) select i).FirstOrDefault();
if (lbGolfer != null)
{
txtFName.Text = lbGolfer.FirstName;
txtLName.Text = lbGolfer.LastName;
txtHandiCap.Text = lbGolfer.Handicap.ToString();
txtLastScore.Text = lbGolfer.LastGame.ToString();
txtRank.Text = lbGolfer.RankOnTeam.ToString();
}
}
catch (Exception z)
{
MessageBox.Show(z.Message);
}
} // End lbMembers_SelectedIndexChanged method

private void btnDeleteplayer_Click(object sender, EventArgs e)
{
// Local Method Variables
Golfer lbGolfer = new Golfer();
Team lbTeam = new Team();
try
{
lbTeam = (from x in myTeams where x.TeamName == cbPlayerTeams.Text select x).FirstOrDefault();
myTeams.Remove(lbTeam);
lbGolfer = (from i in lbTeam.Players where i.FirstName + " " + i.LastName == lbMembers.SelectedItem.ToString() select i).FirstOrDefault();
lbTeam.Players.Remove(lbGolfer);
myTeams.Add(lbTeam);
lbMembers.Items.Remove(lbMembers.SelectedItem); //lbMembers.Text.StartsWith(lbGolfer.FirstName);// Remove(lbGolfer.FirstName + " " + lbGolfer.LastName);
txtFName.Clear();
txtLName.Clear();
txtRank.Clear();
txtLastScore.Clear();
txtHandiCap.Clear();
}
catch (Exception n)
{
MessageBox.Show(n.Message);
}
} // End btnDeleteplayer_Click method

private void btnThisTeam_Click(object sender, EventArgs e)
{
// Local Method Variables
Team singleteamreport = new Team();

singleteamreport = (from x in myTeams where x.TeamName == cbViewTeam.Text select x).FirstOrDefault();
int length = singleteamreport.Players.Count();
int counter = 1;
String[] ReportOut = new String[length + 1];

ReportOut[0] = "***********TEAM " + singleteamreport.TeamName + " Ranked #" + singleteamreport.TeamRank.ToString() + "****************";
foreach (Golfer i in singleteamreport.Players)
{
string rep = "Golfer: " + i.FirstName + " " + i.LastName + " Handicap: " + i.Handicap.ToString() + " Last Score: " + i.LastGame.ToString() + " Rank: " + i.RankOnTeam.ToString();
ReportOut[counter] = rep;
counter++;
}
File.WriteAllLines(tbFilePath.Text, ReportOut);
} // End btnThisTeam_Click method

private void btnAllTeams_Click(object sender, EventArgs e)
{
foreach (Team Allteamreport in myTeams)
{
int length = Allteamreport.Players.Count();
int counter = 1;
String[] ReportOut = new String[length + 1];

ReportOut[0] = "***********TEAM " + Allteamreport.TeamName + " Ranked #" + Allteamreport.TeamRank.ToString() + "****************";
foreach (Golfer i in Allteamreport.Players)
{
string rep = "Golfer: " + i.FirstName + " " + i.LastName + " Handicap: " + i.Handicap.ToString() + " Last Score: " + i.LastGame.ToString() + " Rank: " + i.RankOnTeam.ToString();
ReportOut[counter] = rep;
counter++;
}
File.WriteAllLines(tbFilePath.Text, ReportOut);
} // End foreach
} // End btnAllTeams_Click method

private void btnbtnCalucateTeamRanks_Click(object sender, EventArgs e)
{
// Calculate the players rankings then use the best players score to rank the teams
try
{
CalculateTeamMemberRankings();
CalculateTeamScore();
MessageBox.Show("Calculation is complete");
}
catch (Exception n)
{
MessageBox.Show(n.Message);
}
} // End btnbtnCalucateTeamRanks_Click method

private void CalculateTeamMemberRankings()
{
// Local Method Variables
Golfer teamMember = new Golfer();
int counter = 1;

foreach (Team team in myTeams)
{
// Sort Team members on best score
team.Players.Sort(delegate(Golfer p1, Golfer p2)
{
return p1.Score().CompareTo(p2.Score());
});

// Set rank on team based on position in list
foreach (Golfer golfer in team.Players)
{
golfer.RankOnTeam = counter;
counter++;
}
// Reset counter for next teams ranking
counter = 1;
}
} // End CalculateTeamMemberRankings method

private void CalculateTeamScore()
{
// Local Method Variables
Golfer teamMember = new Golfer();
int counter = 1;

// Sort Teams on #1 players score
myTeams.Sort(delegate(Team t1, Team t2)
{
return t1.Score().CompareTo(t2.Score());
});

foreach (Team team in myTeams)
{
team.TeamRank = counter;
counter++;
}
} // End CalculateTeamScore method

private void PopulateComboboxes()
{
// This method is required because the comboboxes do not have the Team list as their data source
foreach (Team team in myTeams)
{
cbUpdateTeam.Items.Add(team.TeamName);
cbViewTeam.Items.Add(team.TeamName);
cbPlayerTeams.Items.Add(team.TeamName);
}
} // End PopulateComboboxes method

static List ReadXML()
{
XmlSerializer reader = new XmlSerializer(typeof(List));
StreamReader file = new StreamReader(@"GolfTeams.xml");
List teams;
teams = (List)reader.Deserialize(file);
file.Close();

return teams;
} // End ReadXML(List) method

static public void WriteXML(List teams)
{
XmlSerializer writer = new XmlSerializer(typeof(List));

StreamWriter file = new StreamWriter(@"GolfTeams.xml");
teams.Sort(delegate(Team t1, Team t2)
{
return t1.TeamRank.CompareTo(t2.TeamRank);
});
writer.Serialize(file, teams);
file.Close();
}

private void Form1_Load(object sender, EventArgs e)
{

} // End WriteXML(List) method
} // End Form1 cLass
} // End Namespace
Customer reply replied 4 years ago
Can you finish it now?
I am at office so cant work on it now...
Will 12 hrs be fine with you?
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok.12 hours will be fine
Ok than see you after 12 hrs.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok
Ok
Ask Your Own Homework Question
Customer reply replied 4 years ago
So, I will get it ready within time frame . Thanks.
Yea definately.
Ask Your Own Homework Question
Customer reply replied 4 years ago
How long does it take now?
Give me 2-3 more hrs.

Also What you provided me is GUI based code and what I am doing is console based code like the last one i did and for writing in the file I am using TXT file not XML File.

Is it fine with you?
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok
Customer reply replied 4 years ago
Can you make it work it on form too ?
Customer reply replied 4 years ago
If you add references and make console app work as form. That will be great.
Customer reply replied 4 years ago
So, it will be ready in hour or two now.
Yes but form conversion will take lot of time which is not possible now in short time.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok.It will be more better with form conversion.
Than I will have to change the major part of codes which will again be needing approx 24 hrs because I am busy with my work for 12 hrs so i get only 6 hrs to work on your project and 6 hrs. to sleep.
So will 24 hrs. work If you need in form or you need in console based?
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok. By tomorrow this time will be fine
Customer reply replied 4 years ago
you can give me both version console and form by tomorrow this time. OR you can give me console now and form version tomorrow.Thanks.
Ok I will try to post both otherwise Form code for sure because I already started changing on the orignal project.
Ask Your Own Homework Question
Customer reply replied 4 years ago
That will be great.Both will be awesome.
Ok I will provide both.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Hi, you said you gonna finish by tonight right.
Customer reply replied 4 years ago
How long does it take now?
Customer reply replied 4 years ago
Hi, Are you going to finish by tonight right?
Yes how many hrs. Are left?
Ask Your Own Homework Question
Customer reply replied 4 years ago
How many more hours you need?
Some where around 3 hrs.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok. 3-4 hrs will be perfectly fine.
Ok than will leave you a message when done.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok.I will check back after3-4 hrs.
Customer reply replied 4 years ago
Is it done now?
Customer reply replied 4 years ago
How long does it take from here?
Customer reply replied 4 years ago
I am waiting for your reply.
Customer reply replied 4 years ago
Hello, you said 3-4 hrs. But. It is more than that. Can you please tell me how long do you gonna take more? Are you able to give me today?
Customer reply replied 4 years ago
You are still working with question.Thanks.
Customer reply replied 4 years ago
I did not see any solution here. If you need little bit more time, let me know.
Customer reply replied 4 years ago
Hi, I did not hear from you.Are you able to give me by tonight or not?Thanks.
Customer reply replied 4 years ago
Relist: No answer yet.
Customer reply replied 4 years ago
I don't know why I relisted again.Are you still working on this right.
Customer reply replied 4 years ago
Hi, Are you still working on it?
Customer reply replied 4 years ago
Hi, you must be busy with something. But, if you get time, please reply me.
Customer reply replied 4 years ago
Hello
Customer reply replied 4 years ago

Hi,


I would like to know when you gonna finish this?

Customer reply replied 4 years ago
Can I still depend on you or I have to find other ways?
Customer reply replied 4 years ago
Relist: No answer yet.
Josie-Mod
Category: Homework
Satisfied Customers: 5
Verified
Hi, I'm a Moderator for this topic. I've been working hard to find a professional to assist you right away, but sometimes finding the right professional can take a little longer than expected.

I wonder whether you're ok with continuing to wait for an answer. If you are, please let me know and I will continue my search. If not, feel free to let me know and I will cancel this question for you. Thank you!
Ask Your Own Homework Question
Customer reply replied 4 years ago
Yep
Thank you for your continued patience. We will continue the search for a professional for you.
Ask Your Own Homework Question
Customer reply replied 4 years ago

Console application will be good.

Customer reply replied 4 years ago

May be Raj can give me console app.

I am really sorry for not replying here.
Was out of city with no inter net connection there.
Was sent there by my company for project.
Just came back home.

Do you still need the solution files?
Ask Your Own Homework Question
Customer reply replied 4 years ago
Can you give me by tonight?
Customer reply replied 4 years ago
Console or form based whatever would be easy is fine.
Customer reply replied 4 years ago
Yep.
OK I will definitely reply with an solution before midnight
Ask Your Own Homework Question
Customer reply replied 4 years ago
Thanks.That will work.
You are welcome.
Ask Your Own Homework Question
Customer reply replied 4 years ago
So, u have all the requirements right.
Customer reply replied 4 years ago
Hi, console or windows form any will be fine.
Customer reply replied 4 years ago
Hi, you will be able to give me solution tonight. Let me know if you need more hours. Thanks.
Customer reply replied 4 years ago
Raj, Are you going to give me solution on this or not? Please let me know.Thanks.
Customer reply replied 4 years ago
I believe you will reply with solution. Thanks.
Almost done. Give me 30 min max.
Ask Your Own Homework Question
Customer reply replied 4 years ago
Ok. Take your time. No rush. If I get it by tonight . It will be perfectly fine.
I have compressed the whole project together.
The Output file is generated after you exit using the Menu Option 4 and is Generated with name Golf_Team.txt at the below path of the project folder.

Golf_league\Golf_league\bin\Debug

Please download the Compressed solution file(Golf_league.zip) freom the link below:
http://www.mediafire.com/?v4xvxv5yw5eyjpu

If you face any difficulty than feel free to ask for help.

If the solution file is satisfactory than Please don't forget to RATE the Answer.
It will hardly take few seconds to RATE my Answer

Thank You and Have a Good Day.


Ask Your Own Homework Question
Customer reply replied 4 years ago

i did not see any output.

Customer reply replied 4 years ago

here is code :


using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace ConsoleApplication1
{
/*----------------------START OF PLAYER CLASS------------------------------------*/
//PLAYER CLASS
//Player Class consists of the main variables for a player
// and their respective GET/SETs
public class Player
{
//Variable Declarations
string firstName, lastName, msg;
double handicap;
int lastGameScore;


//Read-Write Property
public string FirstName
{
get
{
return firstName;
}
set
{
msg = "\nYou did not enter a valid First name...Please try again.\n";
if (value.Length == 0)
throw (new Exception(msg));
for (int j = 0; j < value.Length; j++)
{
if (!char.IsLetter(value, j))
throw (new Exception(msg));
}
firstName = value;
}
}


//GET/SET For lastName variable
public string LastName
{
get
{
return lastName;
}
set
{
msg = "\nYou did not enter a valid Last name...Please try again.\n";
if (value.Length == 0)
throw (new Exception(msg));
for (int j = 0; j < value.Length; j++)
{
if (!char.IsLetter(value, j))
throw (new Exception(msg));
}
lastName = value;
}
}


//GET/SET For handicap variable
public double Handicap
{
get
{
return handicap;
}
set
{
msg = "\nYou did not enter a valid handicap...Please try again.\n";
if (value < 0)
throw (new Exception(msg));
handicap = value;
}
}


//GET/SET For lastGameScore variable
public int LastGameScore
{
get
{
return lastGameScore;
}
set
{
msg = "\nYou did not enter a valid score...Please try again.\n";
if (value < 9)
throw (new Exception(msg));
lastGameScore = value;
}
}


//GET/SET For playerTeamRank variable
public int PlayerTeamRank
{ get; set; }
}
/*-------------------------END OF PLAYER CLASS--------------------------------------*/


 


/*-------------------------START OF TEAM CLASS---------------------------------------*/
public class Team : Player
{
//Variable Declarations
int spaceCounter, teamScore;
string teamName;
bool isGoodValue;
//Team object has an array of 4 Player objects
public Player[] teamPlayer = new Player[4];


//GET/SET For teamName variable
public string TeamName
{
get
{
return teamName;
}
set
{
spaceCounter = 0;
for (int j = 0; j < value.Length; j++)
{
if (char.IsSeparator(value, j))
++spaceCounter;
}
if ((value.Length == 0) || (spaceCounter == value.Length))
throw (new Exception("\nYou did not enter a valid Team name.....Please try again.\n"));
teamName = value;
}
}


//GET/SET For teamRank variable
public int TeamRank
{ get; set; }
Golfer teamMember = new Golfer();
int counter = 1;
private void CalculateTeamMemberRankings()
{
foreach (Team team in myTeams)
{
// Sort Team members on best score
team.Players.Sort(delegate(Golfer p1, Golfer p2)
{
return p1.Score().CompareTo(p2.Score());
});


// Set rank on team based on position in list
foreach (Golfer golfer in team.Players)
{
golfer.RankOnTeam = counter;
counter++;
}
// Reset counter for next teams ranking
counter = 1;
}
} // End CalculateTeamMemberRankings method



//GET/SET For teamScore variable
public int TeamScore
{
get
{
int sumOfScores = 0;


for (int n = 0; n < this.teamPlayer.Length; ++n)
{
sumOfScores += this.teamPlayer[n].LastGameScore;
}


this.teamScore = sumOfScores / this.teamPlayer.Length;
return teamScore;
}
}


//FUNCTION GetLeagueInfo() - Passes an array of Team - params for variable array
public void GetLeagueInfo(params Team[] golfTeam)
{
//Local Variable tmpTeamName
string tmpTeamName;


//WHILE LOOP - While isGoodValue=false
//INPUT FOR TEAM NAME
while (!isGoodValue)
{
//TRY/CATCH BLOCK - Catches improper input in team name
try
{
//Output and input to gather Team Name (sets tmpTeamName)
Console.Write("Enter Golf Team Name: ");
tmpTeamName = Console.ReadLine();


//FOR LOOP - Scans the golfTeam array passed into the function for duplicates of team name
for (int f = 0; f < golfTeam.Length; ++f)
{
//If the name is XXXXX XXXXX it throws an exception
if (Equals(tmpTeamName, golfTeam[f].TeamName))
throw (new Exception("Sorry, the Team Name is XXXXX XXXXX"));
}


//If no errors and no duplicates, TeamName is XXXXX XXXXX tmpTeamName
this.TeamName = tmpTeamName;
//Sets isGoodValue=true to terminate WHILE LOOP
isGoodValue = true;
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}//END OF WHILE LOOP


//FOR LOOP FOR PLAYER INFORMATION
for (int n = 0; n < this.teamPlayer.Length; ++n)
{
//isGoodValue is reset to false to initiate next while loop
isGoodValue = false;
//Creates a new Player object in the array
this.teamPlayer[n] = new Player();


//WHILE LOOP - While isGoodValue=false
//INPUT FOR FIRST HAME
while (!isGoodValue)
{
try
{
Console.Write("\nEnter a First Name for Player #{0} of Team {1}: ", n + 1, this.TeamName);
this.teamPlayer[n].FirstName = Console.ReadLine();
isGoodValue = true;
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}//END WHILE LOOP


//isGoodValue is reset to false to initiate next while loop
isGoodValue = false;


//WHILE LOOP - While isGoodValue=false
//INPUT FOR LAST NAME
while (!isGoodValue)
{
try
{
Console.Write("Enter a Last Name for Player #{0} of Team {1}: ", n + 1, this.TeamName);
this.teamPlayer[n].LastName = Console.ReadLine();
isGoodValue = true;
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}


}//END WHILE LOOP


//isGoodValue is reset to false to initiate next while loop
isGoodValue = false;


//WHILE LOOP - While isGoodValue=false
//INPUT FOR HANDICAP
while (!isGoodValue)
{
try
{
Console.Write("Enter a handicap for Player #{0} of Team {1}: ", n + 1, this.TeamName);
this.teamPlayer[n].Handicap = Convert.ToDouble(Console.ReadLine());
isGoodValue = true;
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}//END WHILE LOOP


//isGoodValue is reset to false to initiate next while loop
isGoodValue = false;


//WHILE LOOP - While isGoodValue=false
//INPUT FOR LAST GAME SCORE
while (!isGoodValue)
{
try
{
Console.Write("Enter the last game score for Player #{0} of Team {1}: ", n + 1, this.TeamName);
this.teamPlayer[n].LastGameScore = Convert.ToInt32(Console.ReadLine());
isGoodValue = true;
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}//END WHILE LOOP


//isGoodValue is reset to false to initiate next while loop
isGoodValue = false;


//WHILE LOOP - While isGoodValue=false
//INPUT FOR PLAYER RANK
while (!isGoodValue)
{
try
{
Console.Write("Enter the team rank for Player #{0} of Team {1} (1-{2}): ", n + 1, this.TeamName, this.teamPlayer.Length);
this.teamPlayer[n].PlayerTeamRank = Convert.ToInt32(Console.ReadLine());
if ((this.teamPlayer[n].PlayerTeamRank > this.teamPlayer.Length) || (this.teamPlayer[n].PlayerTeamRank == 0))
throw (new Exception("\nYou did not enter a valid team ranking. Please try again.\n"));
for (int f = 0; f < n; ++f)
{
if (Equals(this.teamPlayer[n].PlayerTeamRank, this.teamPlayer[f].PlayerTeamRank))
throw (new Exception("Sorry, the Players Team Rank is a duplicate."));
}
isGoodValue = true;


}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
}//END OF WHILE LOOP


}//END OF FOR LOOP FOR INPUTTING PLAYER INFO


}//END OF GETLEAGUEINFO() FUNCTION
}
/*-------------------------END OF TEAM CLASS--------------------------------------*/


 


/*-------------------------START OF GOLFERS CLASS--------------------------------------*/
public class Golfers
{
public static void Main()
{
//Variable declaration
//Creating a new Team array with 10 teams
Team[] golfTeam = new Team[10];
//Default option is y
char option = 'y';


//FOR LOOP - Will allow players to be added to the golfTeam array until 10 teams have been entered
for (int i = 0; i < golfTeam.Length; ++i)
{
//While the option=y (default is y) run through, will be able to set to 'n' to indicate team entry is finished
while (option == 'y')
{
//At position i in golfTeam, create a new Team object
golfTeam = new Team();
//Call the golfTeam function GetLeagueInfo() using the golfTeam object
golfTeam.GetLeagueInfo(golfTeam);
//Default value of local variable isGoodValue=false
bool isGoodValue = false;


//While isGoodValue is not true this loop will run
//As the default is false, after the team information is entered this loop will initiate
while (!isGoodValue)
{
//TRY/CATCH BLOCK - Prompts if a new Team is desired
try
{
Console.Write("\n\nEnter another Team (y/n): ");


//Will parse the input into a char format, and overwrite the option variable
char.TryParse(Console.ReadLine(), out option);


//Converting value of initial to lowercase to make comparison easier.
option = char.ToLower(option);


//IF/ELSE BLOCK - If the value is not n OR y, it will throw an exception at which point the loop will restart
//ELSE if the input IS n OR y, the isGoodValue variable will set to true and loop will terminate
if (option != 'n' && option != 'y')
throw (new Exception("\nYou entered an incorrect option"));
else
isGoodValue = true;
}
//If other exceptions are caught(numbers etc.) this catch clause will catch the exception
catch (Exception error)
{
Console.WriteLine(error.Message);
}


}//END OF SECOND WHILE LOOP


}//END OF INITIAL WHILE LOOP


}//END OF INITIAL LOOP


Console.ReadLine();
}//END OF MAIN()


}//END OF CLASS DECLARATION
/*-------------------------END OF GOLFERS CLASS--------------------------------------*/


}


Can you just fix here to have delegate to sort either by team name or player or team rank.

When you select the option 4.
The program exits.

Then check the following path.
Inside project folder go to folder bin inside that go to debug and there you will find the file with name Golf_Team.txt containing the team and its players organized/sorted
Ask Your Own Homework Question
Customer reply replied 4 years ago
Yes. But I need something like in the above code. You can run it and see it.if you help me to sort with any team name or rank or score with delegates.Thanks.
Customer reply replied 4 years ago
Raj, can you put delegate in your code?
Customer reply replied 4 years ago
I am about to give you ex. Rating. Before that, can you implement delegate concept in your code?thanks.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Raj
Raj, Engineer
Category: Homework
Satisfied Customers: 1,290
Experience: 4 + Experiance in IT Industry
Verified
Raj and 87 other Homework Specialists are ready to help you
Ask your own question now
Customer reply replied 4 years ago
I just rated it.But, I am outside.i might ask you more about delegates after I reach home this afternoon and compile it again.Thanks.
No problem. When ever I get time I will reply but sometimes it might be late response if I am working at any project in my company
Ask Your Own Homework Question
Ask Raj Your Own Question
Raj
Raj
Raj, Engineer
Category: Homework
Satisfied Customers: 1,290
1,290 Satisfied Customers
Experience: 4 + Experiance in IT Industry

Raj is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.

DianeDallas, TX

< Previous | Next >

Meet the Experts:

LogicPro

LogicPro

Engineer

5,672 satisfied customers

Expert in Java C++ C C# VB Javascript Design SQL HTML

Manal Elkhoshkhany

Manal Elkhoshkhany

Tutor

4,549 satisfied customers

More than 5000 online tutoring sessions.

Linda_us

Linda_us

Finance, Accounts & Homework Tutor

3,138 satisfied customers

Post Graduate Diploma in Management (MBA)

Chris M.

Chris M.

M.S.W. Social Work

2,635 satisfied customers

Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

F. Naz

F. Naz

Chartered Accountant

2,158 satisfied customers

Experience with chartered accountancy

Bizhelp

Bizhelp

CPA

1,887 satisfied customers

Bachelors Degree and CPA with Accounting work experience

Seanna

Seanna

Tutor

1,781 satisfied customers

3,000+ satisfied customers, all topics, A+ work

< Previous | Next >

Related Homework Questions
Which if the following is not included unpaid-in capital?
which if the following is not included unpaid-in capital? common stock pain-in capital-donations stock dividend distributable appropriation per loan agreement … read more
F. Naz
F. Naz
Chartered Accountant
CA Finalist & Completed B.com
2,158 satisfied customers
This question is just for Dr. Kakonge. This purpose is to
Hello. This question is just for Dr. Donna Kakonge.This purpose is to pay the payment to Dr. Donna Kakonge on 06/16/2017 again because of something wrong about payment on 06/16/2017.The question on 06… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
A recent survey found that 73% of all adults over 50 wear
A recent survey found that 73% of all adults over 50 wear sunglasses for driving. In a random sample of 20 adults over 50, what is the mean and standard deviation of those that wear sunglasses?… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
Is anyone familiar with Excel??? The link below will take
Is anyone familiar with Excel??? The link below will take you to my question. It is due 02/14/10 Sunday night , but the sooner the better. You will see "1: Five-Year Sales Projections" that is what I … read more
Stephen, MBA
Stephen, MBA
Master's Degree
166 satisfied customers
160 Word min.: Consider the internal control process
160 Word min.: Consider the internal control process required by the Sarbanes-Oxley Act. Do you think the expenses of implementing better internal controls are offset by the benefits of having the con… read more
Jane T(LLC)
Jane T(LLC)
Master's Degree
18 satisfied customers
I would ask this in homework but I think this is out of
Hi,I would ask this in homework but I think this is out of their area of expertise. How much to answer these 40 electrician trade school questions from Penn foster. This is their NEC graded project wh… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
I have questions on teh fundamental accounting principles
I have questions on teh fundamental accounting principles book nineteenth edition. chapter 11. if you do hit me up… read more
Brittany
Brittany
Bachelor\u0027s Degree
102 satisfied customers
I see you have already done this project but i dont see the
hello i see you have already done this project but i dont see the essay part of it or the brainstorm page it needed done,i am in need of these asap,if you can contact me that would be great,thnx “Evil… read more
O. Adames
O. Adames
Bachelor\u0027s Degree
77 satisfied customers
I need help on how to figure out this problem, I am having
Hello, I need help on how to figure out this problem … read more
GLENN
GLENN
Master of Mathematics
328 satisfied customers
How many words per minute does the average person think? How
Good afternoon, how many words per minute does the average person think? … read more
GLENN
GLENN
Master of Mathematics
328 satisfied customers
Section 1 – Objectives: Provide a brief summary of the
Section 1 – Objectives: Provide a brief summary of the project. • Section 2 – Task 1: Basic Web Tracking Mechanism: Summarize your efforts to investigate web tracking, including the screenshots you to… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
I need help implementing expectation maximization algorithm
I need help implementing expectation maximization algorithm in python … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
I have 3 more if you want them, i have to pick a heroine,
i have 3 more if you want them, i have to pick a heroine, and do these assignments, let me know, and let me know what its worth, when this one is done, i will send you the other two, and pay seperatel… read more
O. Adames
O. Adames
Bachelor\u0027s Degree
77 satisfied customers
I need help with advanced macroeconomics. I'm having trouble
I'm having trouble with the IS-MP-PC model, showing what would happen if the FFR would be increased, and also if there were to be a tax reform. … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
With a minimum word count of 130: Do you believe business
With a minimum word count of 130: Do you believe business enterprise should be regulated by the federal government or that the marketplace should determine price? Explain your response.… read more
Experienced Teacher
Experienced Teacher
Bachelor\u0027s Degree
394 satisfied customers
Is there any help for Linux beginners testout chapter exams.
is there any help for Linux beginners testout chapter exams … read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
185 satisfied customers
Prepare 10 column work sheet for fiscal year 2005 starting
prepare 10 column work sheet for fiscal year 2005 starting with unadjust trial balance including adjustments on additional facts?… read more
Manal Elkhoshkhany
Manal Elkhoshkhany
Tutor
Foundation classes for MBA
4,549 satisfied customers
Need an SQL query written that will create a row for every
Need an SQL query written that will create a row for every possible date. I need it to take all invoices, payments and exchange rates and create a row for each record so that it can be filtered by exa… read more
The-PC-Guy
The-PC-Guy
Bachelor\u0027s Degree
628 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x