Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Advanced Desktop & Basic Cloud Programming Questions 1. The current game client has a problem. From the Options dialog box, you can set the skill

Advanced Desktop & Basic Cloud Programming Questions 1. The current game client has a problem. From the Options dialog box, you can set the skill level of the computer. The problem is that the radio buttons are not updated to reflect the choice the next time you open the Options dialog box. This is partly because there is nothing that tries to update them and partly because there is no value converter from ComputerSkillLevel. Fix this problem by creating a new value converter and setting the IsChecked binding instead of using the Checked event that is currently being used. Hint: You must use the ConverterParameter part of the Converter binding.

2. The computer cheats, so you might want to allow the players to cheat as well. On the Options dialog box, create option for the computer to play with open cards.

3. Create status bar at the bottom of the game client that displays the current state of the game.

4. What information would you need to pass between the browser and the server to play the card game?

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Ch13CardLib

{

public class Card : ICloneable

{

public readonly Rank rank;

public readonly Suit suit;

///

/// Flag for trump usage. If true, trumps are valued higher

/// than cards of other suits.

///

public static bool useTrumps = false;

///

/// Trump suit to use if useTrumps is true.

///

public static Suit trump = Suit.Club;

///

/// Flag that determines whether aces are higher than kings or lower

/// than deuces.

///

public static bool isAceHigh = true;

private Card()

{

}

public Card(Suit newSuit, Rank newRank)

{

suit = newSuit;

rank = newRank;

}

public object Clone() => MemberwiseClone();

public override string ToString() => "The " + rank + " of " + suit + "s";

public static bool operator ==(Card card1, Card card2) => (card1?.suit == card2?.suit) && (card1?.rank == card2?.rank);

public static bool operator !=(Card card1, Card card2) => !(card1 == card2);

public override bool Equals(object card) => this == (Card)card;

public override int GetHashCode() => 13 * (int)suit + (int)rank;

public static bool operator >(Card card1, Card card2)

{

if (card1.suit == card2.suit)

{

if (isAceHigh)

{

if (card1.rank == Rank.Ace)

{

if (card2.rank == Rank.Ace)

return false;

else

return true;

}

else

{

if (card2.rank == Rank.Ace)

return false;

else

return (card1.rank > card2.rank);

}

}

else

{

return (card1.rank > card2.rank);

}

}

else

{

if (useTrumps && (card2.suit == Card.trump))

return false;

else

return true;

}

}

public static bool operator <(Card card1, Card card2) => !(card1 >= card2);

public static bool operator >=(Card card1, Card card2)

{

if (card1.suit == card2.suit)

{

if (isAceHigh)

{

if (card1.rank == Rank.Ace)

{

return true;

}

else

{

if (card2.rank == Rank.Ace)

return false;

else

return (card1.rank >= card2.rank);

}

}

else

{

return (card1.rank >= card2.rank);

}

}

else

{

if (useTrumps && (card2.suit == Card.trump))

return false;

else

return true;

}

}

public static bool operator <=(Card card1, Card card2) => !(card1 > card2);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions