object - Initialize either empty pile of cards or a full deck with a bool in C# -


ok, have write solitaire game , first thing have create card class , pile class.

card class initializes either blank card or defined card...

public enum suit { clubs, diamonds, hearts, spades }  public enum facevalue {     two, three, four, five, six, seven, eight, nine,     ten, jack, queen, king, ace }  public enum color {     red, black }    public class card{     private facevalue facevalue;     private suit suit;     private color color;       //construct blank card     public card() { }       // constuct defined card     public card(facevalue fv, suit s, color c) {         facevalue = fv;         suit = s;         color = c;     } 

and then, here cardpile class

    //create empty cardpile     public cardpile() { }      public list<card> pile;     public cardpile(bool newdeckquestionmark) {         pile = new list<card>();         if (newdeckquestionmark) {             int index = 0;             int c;             foreach (suit s in enum.getvalues(typeof(suit))) {                 foreach (facevalue fv in enum.getvalues(typeof(facevalue))) {                     if ((index < 13) || (index > 38)) {                         c = (int)color.red;                     } else {                         c = (int)color.black;                     }                      pile.add(new card()); // works                     // pile.add(new card (fv, s, c)); // - fails.                     index++;                 }             }         }     } } 

}

i don't know i've gone wrong, whether it's in card properties or in how i'm writing pile.add want foreach facevalue, foreach suit loop insert 52 cards....

when put in

pile.add(new card (fv, s, c)); 

i error,

the best overloaded method match 'shared_game_class_library.card.card(shared_game_class_library.facevalue, shared_game_class_library.suit, shared_game_class_library.color)' has invalid arguments...

c int, , constructor expecting color:

public card(facevalue fv, suit s, color c) 

you cast c color, should change declared type of c color. there's no reason can see use int.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -