Hello Everyone! I'm new at C#, and Would extremely appreciate any guidance =)
Stack at this assignment and have a big hope the community can guide me through the process or at least partially. While unfortunately there is no feedback on my course at all.
I'm still trying to read the Microsoft documentation and test other steps.
I'm not asking for a ready solution, but hope someone could at least give me just the right direction to move.
+May be someone could give an advice for additional information on where I can get more practice with arrays and lists ... maybe there is a trusted platform that generates assignments for different C# topics.
Here I'm.
My objectives:
1. Store the cards in a List
2. Count the number of cards I have for each suit
3. Print the counts of each suit as described below
My steps:
I create a Card List, based on the input number the user gives a for loop is repeated, giving the List the number of cards, from what I understand; GetCard() should give a Card Class/Type instance to every "space" in the List. The Card class has a Suit property that can be Clubs/Diamonds/Hearts/Spades (which was declared) and still doesn't really understand how to be with Ace, King, Jack, and Queen (by using logic they should be declared as I think as well, but don't sure as integers or just a variable). The next for each loop just checks what Value the Suit Property in each Card inside the card List, List equates to, whichever it may happen to be
For example auto grader checks:
Test Case 1: 2 of Clubs, 3 of Diamonds, 4 of Spades, 10 of Spades, Ace of Spades
Test Case 2: 2 of Clubs, 3 of Clubs, 4 of Clubs, 10 of Clubs, Ace of Clubs
If I enter 1
C2 D3 S4 S10 SA (the answer on one line)
If I enter 2
C2 C3 C4 C10 CA (the answer on one line)
Below is my starting code link.
Also in case, someone would like to see the cards library from the course
I would be extremely grateful for any help in the explanation and your time.
Sincerely,
Stack at this assignment and have a big hope the community can guide me through the process or at least partially. While unfortunately there is no feedback on my course at all.
I'm still trying to read the Microsoft documentation and test other steps.
I'm not asking for a ready solution, but hope someone could at least give me just the right direction to move.
+May be someone could give an advice for additional information on where I can get more practice with arrays and lists ... maybe there is a trusted platform that generates assignments for different C# topics.
Here I'm.
My objectives:
1. Store the cards in a List
2. Count the number of cards I have for each suit
3. Print the counts of each suit as described below
My steps:
I create a Card List, based on the input number the user gives a for loop is repeated, giving the List the number of cards, from what I understand; GetCard() should give a Card Class/Type instance to every "space" in the List. The Card class has a Suit property that can be Clubs/Diamonds/Hearts/Spades (which was declared) and still doesn't really understand how to be with Ace, King, Jack, and Queen (by using logic they should be declared as I think as well, but don't sure as integers or just a variable). The next for each loop just checks what Value the Suit Property in each Card inside the card List, List equates to, whichever it may happen to be
For example auto grader checks:
Test Case 1: 2 of Clubs, 3 of Diamonds, 4 of Spades, 10 of Spades, Ace of Spades
Test Case 2: 2 of Clubs, 3 of Clubs, 4 of Clubs, 10 of Clubs, Ace of Clubs
If I enter 1
C2 D3 S4 S10 SA (the answer on one line)
If I enter 2
C2 C3 C4 C10 CA (the answer on one line)
Below is my starting code link.
Also in case, someone would like to see the cards library from the course
I would be extremely grateful for any help in the explanation and your time.
Sincerely,
C#:
using System;
using System.Collections.Generic;
using ConsoleCards;
using static System.Reflection.Metadata.BlobBuilder;
namespace ProgrammingAssignment3
{
/// <summary>
/// Programming Assignment 3
/// </summary>
class Program
{
// autograder support
static int testCaseNumber = 0;
static int nextCard = 0;
static Card[] testCaseCards = new Card[9];
static int numCards = 0;
/// <summary>
/// Programming Assignment 3
/// </summary>
/// <param name="args">command-line args</param>
static void Main(string[] args)
{
// IMPORTANT: Only add code in the section
// indicated below.
string input = Console.ReadLine();
while (input[0] != 'q')
{
testCaseNumber = int.Parse(input);
numCards = GetNumCards();
InitializeTestCaseCards();
nextCard = 0;
// Add your code between this comment
// and the comment below. You can of
// course add more space between the
// comments as needed
#region MyRegion
#region MyRegion
int Clubs = 0;
int Diamonds = 0;
int Hearts = 0;
int Spades = 0;
int AceOfSpades;
int AceOfClubs;
int AceOfHearts;
int AceOfDiamonds;
int JackOfClubs;
int JackOfHearts;
int JackOfSpades;
int JackOfDiamonds;
int KingOfClubs;
int KingOfHearts;
int KingOfSpades;
int KingOfDiamonds;
int QueenOfSpades;
int QueenOfClubs;
int QueenOfHearts;
int QueenOfDiamonds;
List<Card> hand = new List<Card>();
for (int i = 0; i < numCards; i++)
{ hand.Add(GetCard()); }
foreach (Card card in hand)
{
if (card.Suit == Suit.Clubs) Clubs = 2;
if (card.Suit == Suit.Diamonds) Diamonds = 3;
if (card.Suit == Suit.Spades) Spades = 3;
hand.Add(GetCard(Suit.Spades));
if (card.Suit == Suit.Spades) Spades = 10;
}
Console.WriteLine("С" + Clubs + " " + "D" + Diamonds + " " + "S" + Spades + " " + "S" + Spades);
#endregion
#endregion
// Don't add or modify any code below
// this comment
input = Console.ReadLine();
}
}
/// <summary>
/// Gets a card
/// <return>a card</return>
/// </summary>
static Card GetCard()
{
nextCard++;
return testCaseCards[nextCard - 1];
}
/// <summary>
/// Gets how many cards will be in the hand for the
/// current test case number
/// <return>number of cards to add to hand</return>
/// </summary>
static int GetNumCards()
{
switch (testCaseNumber)
{
case 1:
case 2:
case 6:
return 5;
case 3:
return 2;
case 4:
return 7;
case 5:
return 0;
case 7:
return 1;
case 8:
case 10:
return 4;
case 9:
return 9;
default:
return 0;
}
}
/// <summary>
/// Initializes the set of cards returned by GetCard based
/// on the test case number
/// </summary>
static void InitializeTestCaseCards()
{
switch (testCaseNumber)
{
case 1:
testCaseCards[0] = new Card(Rank.Two, Suit.Clubs);
testCaseCards[1] = new Card(Rank.Three, Suit.Diamonds);
testCaseCards[2] = new Card(Rank.Four, Suit.Spades);
testCaseCards[3] = new Card(Rank.Ten, Suit.Spades);
testCaseCards[4] = new Card(Rank.Ace, Suit.Spades);
break;
case 2:
testCaseCards[0] = new Card(Rank.Two, Suit.Clubs);
testCaseCards[1] = new Card(Rank.Three, Suit.Clubs);
testCaseCards[2] = new Card(Rank.Four, Suit.Clubs);
testCaseCards[3] = new Card(Rank.Ten, Suit.Clubs);
testCaseCards[4] = new Card(Rank.Ace, Suit.Clubs);
break;
case 3:
testCaseCards[0] = new Card(Rank.Ten, Suit.Diamonds);
testCaseCards[1] = new Card(Rank.Ace, Suit.Diamonds);
break;
case 4:
testCaseCards[0] = new Card(Rank.Two, Suit.Hearts);
testCaseCards[1] = new Card(Rank.Three, Suit.Hearts);
testCaseCards[2] = new Card(Rank.Four, Suit.Hearts);
testCaseCards[3] = new Card(Rank.Five, Suit.Hearts);
testCaseCards[4] = new Card(Rank.Six, Suit.Hearts);
testCaseCards[5] = new Card(Rank.Seven, Suit.Hearts);
testCaseCards[6] = new Card(Rank.Eight, Suit.Hearts);
break;
case 6:
testCaseCards[0] = new Card(Rank.Ten, Suit.Clubs);
testCaseCards[1] = new Card(Rank.Jack, Suit.Clubs);
testCaseCards[2] = new Card(Rank.Queen, Suit.Clubs);
testCaseCards[3] = new Card(Rank.King, Suit.Clubs);
testCaseCards[4] = new Card(Rank.Ace, Suit.Clubs);
break;
case 7:
testCaseCards[0] = new Card(Rank.Queen, Suit.Hearts);
break;
case 8:
testCaseCards[0] = new Card(Rank.Jack, Suit.Clubs);
testCaseCards[1] = new Card(Rank.Jack, Suit.Diamonds);
testCaseCards[2] = new Card(Rank.Jack, Suit.Hearts);
testCaseCards[3] = new Card(Rank.Jack, Suit.Spades);
break;
case 9:
testCaseCards[0] = new Card(Rank.Two, Suit.Spades);
testCaseCards[1] = new Card(Rank.Three, Suit.Spades);
testCaseCards[2] = new Card(Rank.Four, Suit.Spades);
testCaseCards[3] = new Card(Rank.Five, Suit.Spades);
testCaseCards[4] = new Card(Rank.Six, Suit.Spades);
testCaseCards[5] = new Card(Rank.Seven, Suit.Spades);
testCaseCards[6] = new Card(Rank.Eight, Suit.Spades);
testCaseCards[7] = new Card(Rank.Nine, Suit.Spades);
testCaseCards[8] = new Card(Rank.Ten, Suit.Spades);
break;
case 10:
testCaseCards[0] = new Card(Rank.Two, Suit.Clubs);
testCaseCards[1] = new Card(Rank.Three, Suit.Diamonds);
testCaseCards[2] = new Card(Rank.Four, Suit.Hearts);
testCaseCards[3] = new Card(Rank.Five, Suit.Spades);
break;
default:
break;
}
}
}
}
[ICODE][ISPOILER][ISPOILER][/ISPOILER][/ISPOILER]
[/ICODE]Attachments
Last edited: