Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A0132499W:Tennis Point Program #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 203 additions & 2 deletions TennisScorer1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,209 @@ static void Main(string[] args)

static void DisplayScore(int a, int b)
{
//Modify this method - use ifs and switches based on the value of a and b
Console.WriteLine("____");

switch (a)
{
case 0:
Console.WriteLine((b == 0) ? "Love all" : (b == 1) ? "Love-15" : (b == 2) ? "Love-30" : (b == 3) ? "Love-40" : (b == 4) ? "Game B" : "N/A");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it looks compact, but you actually only listing down all the possible permutations and tackling it one by one. Try to combine some of the cases so the actual number of permutation can be reduced.

//DisplayScore0(b);
break;
case 1:
Console.WriteLine((b == 0) ? "15-love" : (b == 1) ? "15 all" : (b == 2) ? "15-30" : (b == 3) ? "15-40" : (b == 4) ? "Game B" : "N/A");
//DisplayScore1(b);
break;
case 2:
Console.WriteLine((b == 0) ? "30-love" : (b == 2) ? "30-15" : (b == 2) ? "30 all" : (b == 3) ? "30-40" : (b == 4) ? "Game B" : "N/A");
//DisplayScore2(b);
break;
case 3:
Console.WriteLine((b == 0) ? "40-love" : (b == 1) ? "40-15" : (b == 2) ? "40-30" : (b == 3) ? "Deuce" : (b == 4) ? "Advantage B" : "Game B");
//DisplayScore3(b);
break;
case 4:
Console.WriteLine((b == 0) ? "Game A" : (b == 1) ? "Game A" : (b == 2) ? "Game A" : (b == 3) ? "Advantage A" : (b == 4) ? "Deuce" : "Advantage B");
//DisplayScore4(b);
break;
case 5:
Console.WriteLine((b == 0) ? "N/A" : (b == 1) ? "N/A" : (b == 2) ? "N/A" : (b == 3) ? "Game A" : (b == 4) ? "Advantage A" : "Deuce");
//DisplayScore5(b);
break;
default:
break;


}

}
//static void DisplayScore0(int b)
//{
// switch(b)
// {
// case 0:
// Console.WriteLine("Love all");
// break;
// case 1:
// Console.WriteLine("Love-15");
// break;
// case 2:
// Console.WriteLine("Love-30");
// break;
// case 3:
// Console.WriteLine("Love-40");
// break;

// case 4:
// Console.WriteLine("Game B");
// break;

// case 5:
// Console.WriteLine("N/A");
// break;

// }



//}
//static void DisplayScore1(int b)
//{
// switch (b)
// {
// case 0:
// Console.WriteLine("15-love");
// break;
// case 1:
// Console.WriteLine("15 all");
// break;
// case 2:
// Console.WriteLine("15-30");
// break;
// case 3:
// Console.WriteLine("15-40");
// break;

// case 4:
// Console.WriteLine("Game B");
// break;
// case 5:
// Console.WriteLine("N/A");
// break;

// }



//}
//static void DisplayScore2(int b)
//{
// switch(b)
// {
// case 0:
// Console.WriteLine("30-love");
// break;
// case 1:
// Console.WriteLine("30-15");
// break;
// case 2:
// Console.WriteLine("30 all");
// break;
// case 3:
// Console.WriteLine("30-40");
// break;

// case 4:
// Console.WriteLine("Game B");
// break;

// case 5:
// Console.WriteLine("N/A");
// break;
// }


//}
//static void DisplayScore3(int b)
//{
// switch (b)
// {
// case 0:
// Console.WriteLine("40-love");
// break;
// case 1:
// Console.WriteLine("40-15");
// break;
// case 2:
// Console.WriteLine("40-30");
// break;
// case 3:
// Console.WriteLine("Deuce");
// break;

// case 4:
// Console.WriteLine("Advantage B");
// break;

// case 5:
// Console.WriteLine("Game B");
// break;

// }
//}
//static void DisplayScore4(int b)
//{
// switch(b)
// {
// case 0:
// Console.WriteLine("Game A");
// break;
// case 1:
// Console.WriteLine("Game A");
// break;
// case 2:
// Console.WriteLine("Game A");
// break;
// case 3:
// Console.WriteLine("Advantage A");
// break;

// case 4:
// Console.WriteLine("Deuce");
// break;
// case 5:
// Console.WriteLine("Advantage B");
// break;


// }

//}
//static void DisplayScore5(int b)
//{
// switch (b)
// {
// case 0:
// Console.WriteLine("N/A");
// break;
// case 1:
// Console.WriteLine("N/A");
// break;
// case 2:
// Console.WriteLine("N/A");
// break;
// case 3:
// Console.WriteLine("Game A");
// break;

// case 4:
// Console.WriteLine("Advantage A");
// break;
// case 5:
// Console.WriteLine("Deuce");
// break;


// }

//}
}
}