Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# remove duplicate cards

public void displayCards(List<ImageView> disp) {

    int cardNumber = 0;
    Set<Card> myCards = new HashMap<Card>();
    for (ImageView c : disp) {

        cardNumber++;

        Card newCard;

        do {
            rank = rand(13) + 2;
            int i = rand(4);
            if (i == 0) {
                suit = 's';
            } else if (i == 1) {
                suit = 'h';
            } else if (i == 2) {
                suit = 'd';
            } else {
                suit = 'c';
            }
            newCard = new Card(rank, suit);
        } while(myCards.contains(newCard));

        myCards.add(newCard);


        if (cardNumber == 1) {
            dc1 = newCard;
        } else if (cardNumber == 2) {
            dc2 = newCard;
        } else if (cardNumber == 3) {
            dc3 = newCard;
        } else if (cardNumber == 4) {
            pc1 = newCard;
        } else if (cardNumber == 5) {
            pc2 = newCard;
        } else {
            pc3 = newCard;
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: multidimensional meaning 
Csharp :: chrome devtools capture all styling an element uses 
Csharp :: windows forms webbrowser navigate 
Csharp :: edit opened excel file directly 
Csharp :: .net framework method 
Csharp :: text mesh pro 
Csharp :: c# load button image from resource 
Csharp :: c# object to xmldocument 
Csharp :: C# check control type 
Csharp :: unity phone vibration 
Csharp :: unity mix gradient colors 
Csharp :: c# how to use or operator on integers in while loop 
Csharp :: serenity.is get entity columns as ienumerable string 
Csharp :: unity check if animator has parameter 
Csharp :: c# printwindow 
Csharp :: unity disable the display of the camera frustrum 
Csharp :: c# parsing datetime from string irrespctive of culture 
Csharp :: how to clone something as a parent unity 
Csharp :: how to change the scale of a gameobject in unity 
Csharp :: Last N lines from file 
Csharp :: Strings build-in functions in c# 
Csharp :: how to integrate a c# and angular 9 
Csharp :: ExecuteResultAsync ActionContext statuscode 
Csharp :: C# if with obj params 
Csharp :: c# list.except compare classes with IEqualityComparer 
Csharp :: how to change an object color with fill c# 
Csharp :: Initalize C# project in VS Code 
Csharp :: tempdata serializer cannot erorr 
Csharp :: Web API - Stream large file to client 
Csharp :: unity custom editor draw line in scene 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =