Object Oriented – BlackJack in C # Console Based – Tracking

I've refactored the code of my BlackJack into C # based console. Finally, we have found a better solution to solve the problems related to Aces (the double Aces must be the value 22 and the third Ace must be the value 1)

I'm still struggling to divide the user interface and logic of the program although I've created a static screen class for this. Secondly, I still can not understand the purpose or need of having the Hand Course as suggested by some. Enjoy a code review regarding the design pattern or further refactoring of the code for this version of my BlackJack.

Connections

Card class

using the system;
using System.Collections.Generic;

public enum suit
{
Diamonds, clubs, hearts, spades
}

public enum Face
{
As, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten,
Jack, queen, king
}



public class card
{
Public Suit Suit {get; }
face public face {get; }
public string FaceName {get; }

// set value is for As, because As can be 1 or 11.
public int Value {get; together; }

public character symbol {get; }

public ConsoleColor CardColor {get; together; }

/// Initialize value and costume symbol
public card (costume, face)
{
Costume = costume;
Face = face;

switch (costume)
{
Suit.Clubs case:
Symbol = ♣ & # 39 ;;
CardColor = ConsoleColor.White;
Pause;
Suit.Spades case:
Symbol = ♠ & # 39 ;;
CardColor = ConsoleColor.White;
Pause;
Suit.Diamonds case:
Symbol = ♦ & # 39 ;;
CardColor = ConsoleColor.Red;
Pause;
Suit.Hearts case:
Symbol = ♥ & # 39 ;;
CardColor = ConsoleColor.Red;
Pause;
}

switch (face)
{
Face.Ten case:
Value = 10;
FaceName = "10";
Pause;
Face.Jack case:
Value = 10;
FaceName = "J";
Pause;
Face.Queen affair:
Value = 10;
FaceName = "Q";
Pause;
Face.King case:
Value = 10;
FaceName = "K";
Pause;
Face.Ace case:
Value = 11;
FaceName = "A";
Pause;
default:
Value = (int) face + 1;
FaceName = Value.ToString ();
Pause;
}
}

public cancellation PrintCardColor ()
{
Utility.WriteLineInColor ($ "{this.Symbol} {this.FaceName}", this.CardColor);
}

canceled public card PrintCard (Card_card)
{
Console.Write ($ "The drawn map is");
Utility.WriteLineInColor ($ "{_ card.Symbol} {_ card.FaceName}", _card.CardColor);
}
}

Bridge class

using the system;
using System.Collections.Generic;
using System.Linq;

public class Deck
{
// Field
private list platform;


public bridge ()
{
/// Build a deck of 52 cards.
bridge = new list(52);
InitializeColdDeck ();
Mix ();
Screen.PrintShufflingDeck ();
}

private void InitializeColdDeck ()
{
var followsAsList = Enum.GetValues ​​(typeof (Suit)). cast() .ToArray ();

// Another way is below by LINQ. Functional programming.
// This way, more concise and less subject to errors.
bridge = suitAsList
.ChooseMany (
follows => Enumerable.Range (0, 12),
(costume, rank) => new card (suit (costume), rank (face)))
.Lister ();

// Another way is below using 2 for loops:
// This way seems more readable but prone to error.
// for (int j = 0; j <4; j ++)
// for (int i = 0; i < 13; i++)
    //         deck.Add(new Card((Suit)j, (Face)i));
}

// Pick top card and remove it from the deck. 
// Return: The top card of the deck
public Card DrawCard(Player person, bool test = false)
{
    Card card;
    if (test)
    {
        card = new Card(Suit.Clubs, Face.Ace);
    }
    else
    {
        card = deck[0];
    }


    if (person.GetHandValue() + card.Value == 21 && person.Hand.Count == 1)
        // Check natural black jack immediately after received first 2 cards.            
        person.IsNaturalBlackJack = true;
    else if (person.GetHandValue() + card.Value > 21 && card.Face == Face.Ace)
// the number of person hands is not used here because it could have a double Ace in the first two cards.
// only the first aces are counted as 11 while the following ones will be 1
// if the value of the hand is greater than 21
card.Value = 1;

person.Hand.Add (map);
bridge.Remove (map);
return card;
}

/// Randomizes the order of cards in the Deck using the Fisher - Yates random read algorithm.
Private Empty Shuffle ()
{
Random rng = new Random ();

int n = deck.Count;

// Each loop finds a random card to insert into a new card list item.
as long as (n> 1)
{
not--;
int k = rng.Next (n + 1);
Map card = bridge[k];
platform[k] = bridge[n];
platform[n] = map;
}
}

public void ShowRemainingDeckCount ()
{
Console.WriteLine (" nMaps remaining in the package:" + GetRemainingDeckCount ());
}

public int GetRemainingDeckCount ()
{
back deck.Count;
}
}

Player class

using the system;
using System.Collections.Generic;
using System.Threading;

// This class of players is specially designed for the BlackJack game
// Some Player properties only apply to the BlackJack game
public class player
{
public string Name {get; together; }
public list Main {get; together; }

public bool IsNaturalBlackJack {get; together; }

public bool IsBusted {get; together; } = false;

public int TotalWins {get; together; } = 0;
public static int TotalWinsCounter {get; private ensemble; } = 0;


public int ChipsOnHand {get; together; } = 500;

public int ChipsOnBet {get; together; }

public bool Turn {get; together; } = true;

public player (string Name = "Dealer")
{
this.Name = Name;
Main = new list(5);
}
public int GetHandValue ()
{
int value = 0;
foreach (map card in hand)
value + = card.Value;

return value;
}

public void ShowHandValue ()
{
Console.WriteLine (The value of $ "{this.Name} 's hand is: {this.GetHandValue ()} ({this.Hand.Count} cards)");
}

ShowUpCards public void (bool isDealer = false)
{
Console.WriteLine (the hand of $ " n {this.Name} a:");
if (isDealer)
{
Utility.WriteLineInColor ($ "{this.Hand[0].Symbol} {this.Hand[0].FaceName} ", this.Hand[0].CardColor);

Utility.WriteLineInColor ("", ConsoleColor.Magenta);

Console.WriteLine ($ "{this.Name}" Hand value is: {this.Hand[0].Value}");
}
other
{
foreach (map var in this.Hand)
card.PrintCardColor ();

ShowHandValue ();
}
}



public void AddWinCount ()
{
this.TotalWins = ++ TotalWinsCounter;
}

Public Empty Hit (Deck Deck)
{
Console.Write ($ "{this.Name} hits.");
Utility.Sleep ();

// Take a card from the game and place it in the player's hand.
// map map = new map (Suit.Hearts, Face.Ace); //deck.DrawCard ();
Map card = deck.DrawCard (this);
// If there is an Ace in the hand, change its value to 1.
// if (this.GetHandValue () + card.Value> 21 && card.Face == Face.Ace)
// card.Value = 1;

//Hand.Add(card); // Background
card.PrintCardColor (); // UI
Utility.Sleep ();
}

public empty Stand ()
{
Console.WriteLine ($ "{this.Name} is valid."); // UI
Utility.Sleep ();

this.ShowUpCards (); // UI
Utility.Sleep ();

this.Turn = false;
}

public bool CanPlayerStand (bool isPlayerBusted)
{
// The player can remain unconditionally
if (! this.Name.Equals ("Dealer"))
return true;
else if (isPlayerBusted) // to have the dealer automatically switch if the player is stopped
return true;

returns false;
}

public void ResetPlayerHand ()
{
this.Hand = new list(5);
this.IsNaturalBlackJack = false;
this.IsBusted = false;
}
}

Class of screen

using the system;

Static public class screen
{
public static empty SplashScreen ()
{
Console.Write ("Loading");
Utility.printDotAnimation (20);
Console.Clear ();
Console.Title = "Blackjack game based on Steve C # console (version 2)";
Console.Write ("BlackJack game based on the Steve C # console");
Utility.WriteInColor ("", ConsoleColor.White);
Utility.WriteInColor ("♥", ConsoleColor.Red);
Utility.WriteInColor ("", ConsoleColor.White);
Utility.WriteInColor ("♦", ConsoleColor.Red);
}

public static static PromptPlayerName ()
{
Console.Write (" n  nEnter the player name:");
}
blank static public PrintShufflingDeck ()
{
Console.Write ("Shuffle the cold deck");
Utility.printDotAnimation ();
}
}

Utility class

using the system;
using System.Threading;

class utility
{

public static void WriteLineInColor (string text, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.WriteLine (text);
Console.ResetColor ();
}

public void static WriteInColor (string text, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.Write (text);
Console.ResetColor ();
}

empty static public Sleep (int milliseconds = 1500)
{
Thread.Sleep (milliseconds);
}

public void static printDotAnimation (int timer = 10)
{
for (var x = 0; x <timer; x ++)
{
Console.Write (".");
Thread.Sleep (100);
}
Console.WriteLine ();
}

empty static public line ()
{
Console.WriteLine (" n ------------------------------------------- ---- ------- ");
}
}

BlackJackGame class

using the system;
using System.Threading;

public class BlackJackGame
{
private bridge deck;
public void Play ()
{
bool continuePlay = true;
Screen.SplashScreen ();
Screen.PromptPlayerName ();

var player = new Player (Console.ReadLine ());

var dealerComputer = new player ();

deck = new Deck ();

while (continuePlay)
{
// Initialize the screen and reset some properties of the player and the donor
// for the new round.
Console.Clear ();
player.ResetPlayerHand ();
dealerComputer.ResetPlayerHand ();

// Create a new deck if the number of cards remaining is less than 20
if (deck.GetRemainingDeckCount () <20)
deck = new Deck ();

deck.ShowRemainingDeckCount ();

// show the player's bank
Console.WriteLine ($ "{player.Name} Chip Balance: {player.ChipsOnHand}");

if (player.ChipsOnHand <= 10)
{
Utility.WriteLineInColor ("Insufficient token count in your account.", ConsoleColor.Red);
Utility.WriteLineInColor ("Please reload your chips from the counter to continue playing.  N", ConsoleColor.Red);

continuePlay = false;
Pause;
}

// Get the amount of the player bet
Console.Write ("Enter chips:");
player.ChipsOnBet = Convert.ToInt16 (Console.ReadLine ());
// for the sake of brevity, no validation of entry here.

// Distribute the first two cards to the player (background)
deck.DrawCard (player);
deck.DrawCard (player);

// show the player's hand
player.ShowUpCards ();
Utility.Sleep ();

Utility.Line ();

// Distribute the first two cards to the dealer (background)
deck.DrawCard (dealerComputer);
deck.DrawCard (dealerComputer);

// Show the dealer's hand
dealerComputer.ShowUpCards (true);
Utility.Sleep ();

Utility.Line ();

// Check black jack natural
if (CheckNaturalBlackJack (player, dealerComputer) == false)
{
// if both do not have natural blackjack either,
// then, the player's turn to continue.
// After the player's turn, it will be the dealer's turn.
TakeAction (player);
TakeAction (dealerComputer, player.IsBusted);

AnnounceWinnerForTheRound (Player, Computer Reseller);
}

Console.WriteLine ("This turn is over.");

Console.Write (" nplay again? Y or N?");

continuePlay = Console.ReadLine (). ToUpper () == "Y"? right wrong;
// for the sake of brevity, no validation of entry
}

PrintEndGame (player, dealerComputer);
}



TakeAction (Player currentPlayer, bool isPlayerBusted = false)
{
string opt = "";
currentPlayer.Turn = true;

Console.WriteLine (turn of $ " n {currentPlayer.Name}.");

while (currentPlayer.Turn)
{
if (currentPlayer.Name.Equals ("Dealer"))
{
Utility.Sleep (2000); // simulating the reflection time.
// Mini A.I for the dealer.
if (isPlayerBusted) // if the player goes bankrupt, the dealer can win
// Pause; // The dealer is required to reveal the closed card even if the player goes bankrupt
opt = "S";
other
opt = currentPlayer.GetHandValue () <= 16 ? "H" : "S";
        }
        else
        {
            // Prompt player to enter Hit or Stand.
            Console.Write("Hit (H) or Stand (S): ");
            opt = Console.ReadLine();
        }

        switch (opt.ToUpper())
        {
            case "H":
                currentPlayer.Hit(deck);
                currentPlayer.ShowHandValue();

                break;
            case "S":
                //if (currentPlayer.CanPlayerStand(isPlayerBusted))
                currentPlayer.Stand();

                break;
            default:
                Console.WriteLine("Invalid command.");
                break;
        }

        CheckPlayerCard(currentPlayer);
    }

    Console.WriteLine($"{currentPlayer.Name}'s turn is over.");
    Utility.Line();
    Utility.Sleep();
}



private void CheckPlayerCard(Player _currentPlayer)
{
    // If current player is busted, turn is over.
    if (_currentPlayer.GetHandValue() > 21)
{
Utility.WriteLineInColor ("Bust!", ConsoleColor.Red);
Utility.Sleep ();

_currentPlayer.IsBusted = true;
_currentPlayer.Turn = false;
}
// If the total of the player in hand is 5, the turn is over.
else if (_currentPlayer.Hand.Count == 5)
{
Console.WriteLine ($ "{_ currentPlayer.Name} already has 5 cards in hand.");
Utility.Sleep ();

_currentPlayer.Turn = false;
}
}

private bool CheckNaturalBlackJack (player _ player, player _ seller)
{
Console.WriteLine ();
if (_dealer.IsNaturalBlackJack && _player.IsNaturalBlackJack)
{
Console.WriteLine ("The player and the dealer have a natural Blackjack.Tie Game!");
_dealer.ShowUpCards ();
return true;
}
else if (_dealer.IsNaturalBlackJack &&! _player.IsNaturalBlackJack)
{
Console.WriteLine ($ "{_ dealer.Name} got a natural BlackJack. {_Dealer.Name} won!");
_dealer.ShowUpCards ();
_player.ChipsOnHand - = (int) Math.Floor (_player.ChipsOnBet * 1.5);
return true;
}
else if (! _dealer.IsNaturalBlackJack && _player.IsNaturalBlackJack)
{
Console.WriteLine ($ "{_ player.Name} got a natural BlackJack. {_Player.Name} won!");
_player.AddWinCount ();
_player.ChipsOnHand + = (int) Math.Floor (_player.ChipsOnBet * 1.5);
return true;
}

// guard block
returns false;
}

AnnounceWinnerForTheRound (player _player, player _dealer)
{
Console.WriteLine ();
if (! _dealer.IsBusted && _player.IsBusted)
{
Console.WriteLine ($ "{_ dealer.Name} won.");
_dealer.AddWinCount ();
_player.ChipsOnHand - = _player.ChipsOnBet;
}
else if (_dealer.IsBusted &&! _player.IsBusted)
{
Console.WriteLine ($ "{_ player.Name} won.");
_player.AddWinCount ();
_player.ChipsOnHand + = _player.ChipsOnBet;
}
else if (_dealer.IsBusted && _player.IsBusted)
{
Console.WriteLine ("Tie game.");
}
if not (! _dealer.IsBusted &&! _player.IsBusted)
if (_player.GetHandValue ()> _dealer.GetHandValue ())
{
Console.WriteLine ($ "{_ player.Name} won.");
_player.AddWinCount ();
_player.ChipsOnHand + = _player.ChipsOnBet;
}
else if (_player.GetHandValue () <_dealer.GetHandValue ())
{
Console.WriteLine ($ "{_ dealer.Name} won.");
_dealer.AddWinCount ();
_player.ChipsOnHand - = _player.ChipsOnBet;
}

else if (_player.GetHandValue () == _dealer.GetHandValue ())
Console.WriteLine ("Tie game.");

}

printEndGame (player, dealer, computer)
{
Console.WriteLine ($ "{player.Name} has gained {player.TotalWins} times.");
Console.WriteLine ($ "{dealerComputer.Name} earned {dealerComputer.TotalWins} times.");
Console.WriteLine ("Completed game, thank you for playing.");
}
}

javascript – How can I get the background color of my page via the console?

According to SO Teemu's answer in English

You can get there with the use of the method getComputedStyle () which you can read more here: getComputedStyle ()

As following:

let color = window.getComputedStyle (document.body, null) .getPropertyValue ('background color');
console.log (color)

What this method does is to return an object, from which you can access all the CSS properties of the element in question.

References:

groovy – Jenkins scripting console: how to create a build for a job?

From the jenkins script console, how can I create a build for a job?

Tried:

                for (work in Hudson.instance.getView (view_name) .items) {
job.startBuild ()
}

Fault:
groovy.lang.MissingMethodException: No signature of the method: hudson.model.FreeStyleProject.startBuild () does not apply to argument types: () []

column – SPFX call response remaining view in network tab but unable to read on console

I have a problem. I make a call to rest to get the columns from a list, the success of the call because I can see the answer in the Network tab of the development tools. Here's a photo:
enter the description of the image here
for some reason, when I try to console him, he looks like this with and without calling the .json () method:
enter the description of the image here
here is my method:

            export const getListFieldsByGuid = (guid: string, context: WebPartContext)
=> {
returns context.spHttpClient
.get(
context.pageContext.web.absoluteUrl +
`/ _api / web / lists (guid & # 39; $ {guid} & # 39;) / Fields? $ filter = Eq hidden false and
ReadOnlyField eq false`,
SPHttpClient.configurations.v1
)
.then (answer => {
console.log ("fields without .json ():", response);
return response.json ();
});
};

What am I doing wrong?
Plus, if someone has a better way to get specific view columns from a list, I would thank them very much!

Make my website user-friendly for the search console

I would like this site to be verified on https://search.google.com/test/mobile-friendly as mobile friendly

The website is partially loaded. How can I fix js and img files for unloaded mobile phones? I do not know how to correct the errors above.

enter the description of the image here

[WTS]Cheap dedicated servers $ 35! Eight core e5 xeon ★ 16GB ddr3 ★ unlimited bandwidth

Reprise Hosting (AS62838) is a provider of hosting services at the best value for money. We are specialized in low cost hosting solutions for real world hosting needs. We are pleased to offer WebHostingTalk members a new series of cheap dedicated server promotions.

These servers will be hosted at our Seattle, WA contact point in the Westin Building Exchange.

Our combination of NTTE BGP, Abovenet and our excellent Seattle Internet Exchange compatibility (Microsoft, Google, Amazon, Netflix, Akamai, Charter, Telus, T-Mobile, OVH, CloudFlare, Yahoo, etc.) allow us to offer dedicated services . servers withlow ping timeacross the Pacific and the Atlantic:

132ms to Hong Kong(Http://pbrd.co/1GiHx5N)
89ms to Tokyo(Http://pbrd.co/1GiHl6p)
124ms to London(Http://pbrd.co/1GiIdry)
28ms from Los Angeles(Http://pbrd.co/1GiHHKd)
65ms to New York(Http://pbrd.co/1GiIafF)

Results of global ping tests provided by NTT and HE glass servers. These are optimal ping times, routing and pairing your local ISP will determine your latency.

>> HostSearch Reviews
>> Critic # 1 of the WHT client
>> Customer Review WHT # 2
>> Customer Review WHT # 3
>> Critic # 4 of the WHT client
>> Critic # 5 of the WHT client
>> Critic # 6 of the WHT client
>> VPSBoard Recommendation
>> LowEndTalk Review
>> LowEndTalk Positive Feedback # 1
>> LowEndTalk Positive Feedback # 2
>> LowEndTalk recommendation
>> LowEndTalk Recommendations
>> LowEndTalk Positive Feedback # 3

Use the promotional code IWANTUNMETERED to receive free unmeasured bandwidth add-on at 50 Mbps.

Use promo code ZZDED10 to receive a permanent monthly rebate of $ 10. Code expired on 15/07/2019!

Type"WHITE DOUBLE22"in the "How did you hear about us?"box at the checkout and we willDOUBLE the RAMinstalled on your server for free! New customers only. Valid for orders placed on or before 15/07/2019 23:59 PDT.

Do you know someone interested in our servers? Sign up as a Reprise Hosting Affiliate and earn a 10% recurring commission as long as your referrals remain guests!

••••••••••••••••••••••••••••••••••••••••••••
SpecializedReturnEDED
••••••••••••••••••••••••••••••••••••••••••••
"Intel Xeon E5-2650L eight-core processor with hyperthreading (16 threads).
»16 GB of server-level DDR3 memory.
»1 TB SATA hard drive.Free exchange on a 120 GB Crucial M500 SSD on request.
"Premium bandwidth multi-hosted 10 TB on a 100 Mbps port.
"IPMI included for free (remote reboot, console, operating system reload, etc.)!
»4 usable IP addresses (additional IP addresses available).

Only $ 34.95 per month with ZZDED10 promo. FREE installation! Limited quantities.

>> Order now <<

••••••••••••••••••••••••••••••••••••••••••••
RepriseEEDED Special
••••••••••••••••••••••••••••••••••••••••••••
"2x Intel Xeon E5-2650L eight-core processor with hyperthreading (16 cores, 32 threads).
32 GB of server-level registered DDR3 memory.
»1 TB SATA hard drive.Free exchange on a 120 GB Crucial M500 SSD on request.
"Premium bandwidth multi-hosted 10 TB on a 100 Mbps port.
"IPMI included for free (remote reboot, console, operating system reload, etc.)!
»4 usable IP addresses (additional IP addresses available).

Only $ 44.95 per month with ZZDED10 promo. FREE installation! Very limited quantities.

>> Order now <<

••••••••••••••••••••••••••••••••••••••••••••
Optional add-ons
••••••••••••••••••••••••••••••••••••••••••••
"cPanel license: + $ 29.95 a month
"Additional IP: + $ 1.50 per IP per month
"Additional RAM: + $ 3.50 per 2 GB
"1TB additional hard drive: + $ 5.95 per month
"Additional 120GB SSD: + $ 5.95 per month

••••••••••••••••••••••••••••••••••••••••••••
SLA and guarantees
••••••••••••••••••••••••••••••••••••••••••••
99.99% network uptime
»100% availability of food
»100% cooling time
Same day configuration for orders placed before 6pm Pacific time 7 days a week.

Frequently asked questions:

Can I customize my system to include more disk space / memory / bandwidth?
Yes! We can add more memory, secondary hard drives, or increase your bandwidth allocation. The upgrade options are listed on our website or you can contact the sales department.[at]recoveryhosting.com for a custom quote.

Do you make a price match?
Yes! We compare the prices of comparable servers offered by our competitors. Send us an e-mail for sale[at]recoveryhosting.com to get a quote.

Where is your data center?
We have POPs in Las Vegas, NV and Seattle, WA. This dedicated, low-cost dedicated server is located in Seattle, at the Westin Building Exchange.

How do you accept the payment?
We accept payments via PayPal, credit card (Visa, MasterCard, Discover and AmEx), Bitcoin and Alipay.

IP test?
162.253.153.4

.

google – SEO and search issues in the console

Hello, I put online a site there is more than a month but it is still very poorly listed on the occurrences but little compete as the name + geolocation (hotel bay angels landeda, hotel spa landeda …). In the search console, when I inspect the URL, an update on two updates is good / bad (see screenshot) while nothing has changed there would be a canonical problem, but I do not see anything on my side.
I've tested the website on Woorank, seocheck up, speed page, it gets good scores.
Can any one help me detect if there is a problem? It looks like something is wrong with this URL, some people can not see the website because it is suspicious.
enter the description of the image here
enter the description of the image here

How come I can change the keys / values ​​of a site's cookies in development tools, but not the console?

I spent at least two hours trying to edit cookies from a website, like Facebook, through the console. It seems that if I delete c_user on the development tools, I am disconnected. But when I tried to make document.cookie[0]= "c_user = 0", nothing happens.

is there a way to clear the gesture of the Android user to the adb console?

I'm trying to transfer an Android user gesture such as a touch screen (x, y): scan the screen (x1, y1, x2, y2) to the adb console?

by doc, adb shell dumpsys could be used for this.

this order

entry dumpsys shell adb

gives a single output, executes a command once, exports part of the output. what I need is like that,

when I touch somewhere on the screen, adb dump touch x, y, when I sweep, adb dump scan x1, y1, x2, y2

Is there a way to do this?

Ubuntu 16.04 – Application not running on the vnc console but running on KVM

I'm trying to run azuredatastudio on my Ubuntu 16.04 server. I have a VNCServer configuration using an Xvce environment under tightvncserver.

Since this application has a graphical interface and I have to spend a lot of time using it, I thought about opening it on my VNC. But that would not open.

It works well on my Raritan KVM console. The screen resolution is low and the mouse pointer runs irregularly. I hate using it for long hours.

What could go wrong?