Question
CARD GAME LIBRARY ***clubclass.cs using System; using System.Collections.Generic; using System.Text; namespace CardGameLibray { public class ClubClass : ParentCardClass { public ClubClass(Rank pRank) { CardRank =
CARD GAME LIBRARY
***clubclass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public class ClubClass : ParentCardClass { public ClubClass(Rank pRank) { CardRank = pRank; CardSuit = Suit.Club; } public override void Display() { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(CardRank + " of " + CardSuit + "s "); Console.ResetColor(); } } }
***diamondclass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public class DiamondClass : ParentCardClass { public DiamondClass(Rank pRank) { CardRank = pRank; CardSuit = Suit.Diamond; } public override void Display() { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(CardRank + " of " + CardSuit + "s "); Console.ResetColor(); } } }
***HeartClass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public class HeartClass : ParentCardClass { public HeartClass(Rank pRank) { CardRank = pRank; CardSuit = Suit.Heart; } public override void Display() { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(CardRank + " of " + CardSuit + "s "); Console.ResetColor(); } } }
***MyGameClass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public class MyGameClass { public ParentCardClass[] TheDeckOfCards;
public MyGameClass() { TheDeckOfCards = new ParentCardClass[52];
int i = 0; Rank rankIndex = Rank.Deuce;
while (i
}
} }
***ParentCardClass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public abstract class ParentCardClass { public Rank CardRank { get; set; } public Suit CardSuit { get; set; }
public abstract void Display();
} }
***rank.cs
using System;
namespace CardGameLibray { //an enum with 13 values, // Deuce Three Four Five Six Seven Eight Nine Ten Jack Queen King Ace // Deuce has value 2 and the others count up by 1 to the Ace = 14 public enum Rank { Deuce = 2, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace } }
***SpadeClass.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { public class SpadeClass : ParentCardClass { public SpadeClass(Rank pRank) { CardRank = pRank; CardSuit = Suit.Spade; } public override void Display() { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine(CardRank + " of " + CardSuit + "s "); Console.ResetColor(); } } }
***Suit.cs
using System; using System.Collections.Generic; using System.Text;
namespace CardGameLibray { //an enum with 4 values, Club Diamond Heart Spade // where Club has value 1 and the others count up by 1 public enum Suit { Club = 1, Diamond, Heart, Spade } }
FIGHT CARD GAME
***program.cs
using CardGameLibray; using System;
namespace FightCardGame { class Program { static void Main(string[] args) { // a. Create an instance of your MyGameClass class, and name it MyGame. MyGameClass MyGame = new MyGameClass();
// b. Using a foreach, build a loop that calls the Display method // for each card in the MyGame TheDeckOfCards array.
foreach (ParentCardClass item in MyGame.TheDeckOfCards) { item.Display(); } Console.WriteLine(); Console.WriteLine("================================================"); Console.WriteLine("================================================"); Console.WriteLine();
// uncomment this after you impliment the new Sort method in MyGameClass and // the IComparable method in the ParentCardClass // MyGame.Sort();
foreach (ParentCardClass item in MyGame.TheDeckOfCards) { item.Display(); }
// end of program
Console.ReadLine(); } } }
Start with my version of the card homework, makes sure it runs. It should write out the set of 52 cards twice when you run it. 1) Go to the MyGameClass and code a Sort method. It's just one line of code using the Array class's Sort method. It should sort your array of 52 cards. 2) Go to the ParentCardClass and add the IComparableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started