java – How to fix a NULL object bug?

I create load objects to perform unit tests, but the object I'm working on is null, as shown in the red arrow below, at line 39, and I do not understand why that happens, I need help to fix this bug!

insert the description of the image here

The code is here;

Public class TypeIndicioBuilder {

private TypeIndicioEntity typeIndicio;

private TypeIndicioBuilder () {
}

static public TypeIndicioBuilder anTypeIndicio () {

GroupTipoIndicioEntity groupTypeIndication = new GroupTypeIndicioEntity ();
groupTypeIndex.setCode (1);

UserCorporativeEntity UserCorporate = new UserCorporativeEntity ();
userCorporate.setCode (1);

TypeIndicioBuilder builderTypeIndicio = new TypeIndicioBuilder ();
builderTypeIndicum.typeIndicio.setCode (16);
builderTypeIndicum.typeIndicio.setName ("Accumulation2");
builderTypeIndicum.typeDescription ("Linked2");
constructorTipoIndicio.tipoIndicio.setCriterio ("hi ok 2");
constructorTypeIndicum.typeIndicio.setPrazoPadrao (20);
builderTypeIndices.typeIndicio.getGroup ();
builderTypeIndication.typeIndicio.getResponsavel ();
back to manufacturerTipoIndicio;
}

public TypeIndicioEntity returnTypeIndicio () {
returns typeIndicio;
}

}

interaction design – Best way to let the user select something under another object

For an application I'm developing, I've been thinking about an aspect of the user interface. Imagine I have an application that allows me to draw shapes. I can select drawn shapes by clicking inside. But there is a major problem: overlapping shapes are allowed. If one form completely overlaps the other, a user can still see it because it is transparent, but it has no way of selecting it. To be able to select somehow is necessary.

Is there a mechanism commonly used or considered intuitive, in addition to a list of forms in which the superimposed form can be selected? I've been thinking about it for a while and I was looking on Google. I can think of an option: when you click on a shape, I can display next to the shape of small buttons that hide the shape or show the overlapping shape again. But I think it's not really ideal because it might be unintuitive / impossible to discover.

Ideas?

Thanks in advance,
Joshua

8 – Is it possible to execute a function on a user object in Twig?

You can use hook_entity_load to add fields to the user object as follows:

function mymodule_entity_load ($ entities, $ type)
{
if ($ type == & # 39; user)
{
foreach ($ entities as $ e) {
$ e-> myField = "hello";
}
}
}

This will allow me to do it in twig:

{{}} User.myField

It's very useful, but it would be nice if I could do it:

{{user.getActivity ()}}

Or more specifically:

Members

    {% for activity in user.getActivity ()%}
  • {{}} Activité.time
  • {% endfor%}

Is it possible to add a "function" in this way?

oriented object – Chess OO design Movement Logic

I read a lot about the implication of chess and I have thoughts …
In many places, I saw that Piece was the parent and that all types that could be considered elephants were children. There is an abstract method: isValidMove (Box start, Box end, board).
Box (is a coordinate)
Each subclass implements isValidMove.
I wondered if isValidMove should be there and as I understand it, Piece is a simple piece (which does not fit the card) that has color property but the move logic includes the card is not part of this . So what is the best solution? about creating this Piece class with Color Member and enum PieceType member …
The Move class contains the items Start, Box, and End, as below.

public class Move {
private start of the box;
private box end;
Private room pieceMoved;
}

There will be IMoveableStrategy with isValidMove (Move, Board) and then there will be subclasses for each type of room …
Disadvantages: Whenever a new type of part will be added, I have to add this to the part type enumeration and as a new subclass also for the strategy (two places) …
it seems that I write very similar thing: In the first option: Piece and all its options as subclasses.Second: Piece simple type and strategy for each one of them …
So not sure which is better …
pls help me 🙂

Permanent merge of objects into a single object (Adobe Illustrator)

In Adobe Illustrator, I have a file that has a lot of points aligned closely, so that it seems like they are forming a line. The ".ai" file is very large (55 MB). To reduce the size of the file, is there a way to permanently merge the aligned points into a single object?

Note that I know the following options, which I am explicitly do not looking for:

  1. group their,
  2. Transform them into compound path,
  3. Manually replace the points for a line.

The first two options do not work for me because they do not reduce the file size. The third option does not work for me because I have a lot of separate "score lines" so it would be too laborious to replace them all.

However, it may be feasible to separately select each row of points and then convert them to a single object.

In short, to reduce the file size, how can I merge objects permanently and irreversibly into one, please? Thank you.

c # – Unity Collider2D makes disappear the object of the game during a collision

I've gone through just about everything to try to isolate this bug.

I isolated it from the enemy collider, but I did not solve the problem.

When my player collides with my enemy, the enemy game object is destroyed and removed from the hierarchy (until it is reset).

Removing the enemy collider solves this problem of course. However, removing the collider does not do it.

Neither the player nor the enemy have collider code written in their scripts, so I can not blame them for that. An OnEnterCollision2D script was added to the enemy game object, but I deleted it to try to resolve the situation and it did nothing.

There is no other script in play – only the relationship between player and enemy colliders.

I am new to coding, but I can not find anything about it. Any help is very appreciated!

What. The. Damn.

If you want to read the scripts, you can here:
https://forum.unity.com/threads/oncollisionenter2d-is-destroying-my-game-objects-and-i-cannot-figure-out-why.710837/

Object Orientation – Doubt on Python Legacy

Hello, I study POO in Python and I see that it is possible to inherit attributes of a super class in two ways:

Class class_name (class_class_name):
def __init __ (self, args):
super (superclass, self, args)

And also like this:

Class class_name (class_class_name):
def __init __ (self, args):
super_name .__ init __ (self, arguments)

Do both ways do the same thing or are there differences between them?

Unity Editor – Adding Object Fields at One Button Click

Here is a quick code that I wrote. I hope this solves the problem you had.

using System.Collections.Generic;
using UnityEngine;
use UnityEditor;

Public class SomethingEditor: EditorWindow {

Private static list objs = new list();
Private static list floats = new list();
Vector2 static private v = Vector2.zero;

    [MenuItem("MenuItem/Test")]
    Private static Void DoIt () {EditorWindow.GetWindow(); }

void OnGUI () {
EditorGUILayout.BeginScrollView (v);

if (GUILayout.Button ("Create an object")) {
floats.Add (default (float));
objs.Add (default (Object));
}

for (var i = 0; i <objs.Count; i ++) {
objs[i] = EditorGUILayout.ObjectField (objs[i], typeof (Object), false);
floats[i] = EditorGUILayout.FloatField (float[i])
}

if (GUILayout.Button ("Print")) {
for (var i = 0; i <objs.Count; i ++) {
Debug.Log (objs[i])
Debug.Log (float[i])
}
}
EditorGUILayout.EndScrollView ();
}
}

You can obviously make changes to make the editor more beautiful, but you can have something like this.

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.");
}
}

object oriented – Console-based BlackJack in C #

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.");
}
}

Proxy Sites Proxy Tunnels Proxy List Working Proxy Sites Hotproxysite Proxy Sites Proxy Sites Anonymous Proxy Anonymous Proxies Top-Proxies.co.uk http://www.proxysitesnow.com Proxy Servers Free Proxies Free Proxy List Proxy List Zoxy Proxy List PR liste all proxy sites More Proxies netgofree netgofree Hide-MyIp - The Best Proxy List American Proxy List www.proxylisty.com/proxylist Web Proxy Submit Proxies Updated Proxy List Updated Proxy List aproxy.org Bypass Proxy Sites Free Proxies List Evolving Critic Business Web Directory Free Proxy List iShortIt MyProxyList Online Proxies Go Proxies Need Proxies PrivateProxies Proxies4MySchool Proxies4Work Free Proxy List Free Proxy Sites ProxyInside Wiksa Proxy ProxyLister.org Free Proxy List ProxyNoid Proxy List Free Proxy List Proxy Sites Proxy TopList ProxyVille UK Proxy WebProxy List RatedProxy.com - Listing the best Web Proxies Free Proxy List SchoolProxiesList Stay Anonymous Proxy List The Power Of Ninja Proxy List UNubstruct Free proxy sites Free proxy sites