×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Program To Create a Card Game in C Assignment Solutions

June 24, 2024
Dr. Nathan Nguyen
Dr. Nathan
🇦🇺 Australia
C
Dr. Nathan Nguyen holds a PhD in Computer Science from the University of Melbourne in Melbourne, Australia. With over 5 years of experience in the field, he has completed over 500 C programming assignments with utmost proficiency. Dr. Nguyen's expertise lies in algorithm design and optimization, making him a valuable asset in tackling complex programming challenges.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Familiarize yourself with OCaml's pattern matching; it simplifies handling recursive data structures like lists and trees, making your code concise and easier to debug.
News
In 2024, Girls Who Code introduced a Data Science + AI track in their free summer programs for high school students, fostering skills in cybersecurity and creative coding​

Instructions

Objective

Write a C assignment program to create a card game.

Requirements and Specifications

Program-to-create-a-card-game-in-C-language
Program-to-create-a-card-game-in-C-language 1
Program-to-create-a-card-game-in-C-language 2
Program-to-create-a-card-game-in-C-language 3
Program-to-create-a-card-game-in-C-language 4 (1)
Program-to-create-a-card-game-in-C-language 5 (1)
Program-to-create-a-card-game-in-C-language 6 (1)
Program-to-create-a-card-game-in-C-language 7 (2)
Program-to-create-a-card-game-in-C-language 8 (1)
Program-to-create-a-card-game-in-C-language 9 (1)
Program-to-create-a-card-game-in-C-language 10 (1)

Source Code

PLAYING CARDS using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DES1_Week1_PlayingCardAssignment { class PlayingCard { private static char HeartSymbol = Encoding.GetEncoding(437).GetChars(new byte[] { 3 })[0]; private static char DiamondSymbol = Encoding.GetEncoding(437).GetChars(new byte[] { 4 })[0]; private static char ClubSymbol = Encoding.GetEncoding(437).GetChars(new byte[] { 5 })[0]; private static char SpadeSymbol = Encoding.GetEncoding(437).GetChars(new byte[] { 6 })[0]; public static int CardWidth = 5; public static int CardHeight = 3; public enum Suits { Hearts = 0, Diamonds, Spades, Clubs, NUM_SUITS }; public enum Ranks { Ace = 1, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, NUM_RANKS }; // TODO: Implement the required Fields private Suits suit; private Ranks rank; // TODO: Implement the requried Constructor(s) public PlayingCard(Suits suit, Ranks rank) { this.suit = suit; this.rank = rank; } // TODO: Implement the required Methods public Suits GetSuit() { return suit; } public Ranks GetRank() { return rank; } public int GetValue() { if (rank == Ranks.Ace) { return 11; } if (rank == Ranks.Jack || rank == Ranks.Queen || rank == Ranks.King) { return 10; } return (int)rank; } public void DisplayCardAtLocation(int XPosition, int YPosition) { { int currX = 0; int currY = 0; while (currY < YPosition + CardHeight) { if (currY < YPosition) { Console.WriteLine(); currY++; } else { if (currX < XPosition) { Console.Write(" "); currX++; } else { switch (currY - YPosition) { case 0: case 2: Console.WriteLine("*" + RankToString() + SuitToString() + "*"); break; case 1: Console.WriteLine("* *"); break; } currX += CardWidth; } if (currX >= XPosition + CardWidth) { currX = 0; currY++; } } } } } public void DisplayCardBackAtLocation(int XPosition, int YPosition) { int currX = 0; int currY = 0; while (currY < YPosition + CardHeight) { if (currY < YPosition) { Console.WriteLine(); currY++; } else { if (currX < XPosition) { Console.Write(" "); currX++; } else { Console.WriteLine("*****"); currX += CardWidth; } if (currX >= XPosition + CardWidth) { currX = 0; currY++; } } } } // TODO: Implement the required Static Methods public static int CompareCards(PlayingCard card1, PlayingCard card2) { int val1 = card1.GetValue(); int val2 = card1.GetValue(); if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } else { return 0; } } // TODO: Double check the rubric. Did you get all of your points? private String SuitToString() { switch (suit) { case Suits.Spades: return "" + SpadeSymbol; case Suits.Diamonds: return "" + SpadeSymbol; case Suits.Clubs: return "" + ClubSymbol; case Suits.Hearts: return "" + HeartSymbol; default: return ""; } } private String RankToString() { switch (rank) { case Ranks.Ace: return " A"; case Ranks.Two: return " 2"; case Ranks.Three: return " 3"; case Ranks.Four: return " 4"; case Ranks.Five: return " 5"; case Ranks.Six: return " 6"; case Ranks.Seven: return " 7"; case Ranks.Eight: return " 8"; case Ranks.Nine: return " 9"; case Ranks.Ten: return "10"; case Ranks.Jack: return " J"; case Ranks.Queen: return " Q"; case Ranks.King: return " K"; default: return ""; } } } }

Similar Samples

Explore ProgrammingHomeworkHelp.com for a curated selection of sample programming assignments showcasing our expertise. These examples highlight our proficiency in solving diverse coding challenges across multiple programming languages and levels of complexity. Dive into our samples to experience firsthand how we can assist you with your programming needs.