Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help me please.

Please can anyone correct the mistakes and write the PRECONDITIONS and the POSTCONDITIONS, and also put this in three files like the MEMBER FUNCTION, IMPLIMENTATION FILE AND THE CLIENT PROGRAM FILE for me
PLEASE
THANKS



enum Suit {clubs, diamonds ,hearts, spades };

const int jack = 11; // from 2 to 10 are
const int queen = 12; // integers without names
const int king = 13;
const int ace = 14;

class card
{
private:
int number; //2 to 10, jack,queen,king,ace
Suit suit; //clubs,diamonds,hearts,spades
public:
card() // constructor
{}
void init(rank r,Suit s}; // initialize card
{ suit = s; number = n; }
void display(); // displays card
};


void card:: display() //displays the cards
{
if {number >=2 && number <=10 }
cout<< number;
else
switch (number)
{
case jack: cout << "J"; break;
case queen: cout << "Q"; break;
case king: cout << "K"; break;
case ace: cout << "A"; break;
switch (suit)
{
case clubs: cout <<char(5); break;
case :diamonds cout <<char(4); break;
case hearts: cout << char(3); break;
case spades: cout << char(6); break;
}
}


void main()
{
card deck [52];

cout<<endl;
for(int j=0; j<52; j++)
{
int num =(j%13)+2; //cycles through 2 to 14, 4 times
Suit su = Suit(j/13); //cycles through 0 to 3, 13 times
deck[j].init(num,su); // set card


cout<<"
Ordered deck:
";
for( j=0; j<52; j++) //display ordered deck
{
deck[j].display();
cout<<" ";
if(!(j+1) % 13)) //new line every 13 cards
cout<< endl;
}
randomize(); //seed random numbers generator
for(j=0; j<52; j++) //for each card in the deck
{
int k = random(52); // pick another card at random
card temp = deck[j]; //and swap them
deck[j] =deck[k];
deck[k] = temp;
}
cout<< "
shuffled deck:
;
for(j=0; j<5; j++)
{
deck[j].display(); // display shuffled deck
cout<<" ";
if (!( (j+1) % 13 ))
cout<< endl;
}
getch(); //wait for keypress
} //end main

Comments

  • sparcusssparcuss Member Posts: 43
    : Please can anyone correct the mistakes and write the PRECONDITIONS and the POSTCONDITIONS, and also put this in three files like the MEMBER FUNCTION, IMPLIMENTATION FILE AND THE CLIENT PROGRAM FILE for me
    : PLEASE
    : THANKS
    :
    :
    :
    : enum Suit {clubs, diamonds ,hearts, spades };
    :
    : const int jack = 11; // from 2 to 10 are
    : const int queen = 12; // integers without names
    : const int king = 13;
    : const int ace = 14;
    :
    : class card
    : {
    : private:
    : int number; //2 to 10, jack,queen,king,ace
    : Suit suit; //clubs,diamonds,hearts,spades
    : public:
    : card() // constructor
    : {}
    : void init(rank r,Suit s}; // initialize card
    : { suit = s; number = n; }
    : void display(); // displays card
    : };
    :
    :
    : void card:: display() //displays the cards
    : {
    : if {number >=2 && number <=10 }
    : cout<< number;
    : else
    : switch (number)
    : {
    : case jack: cout << "J"; break;
    : case queen: cout << "Q"; break;
    : case king: cout << "K"; break;
    : case ace: cout << "A"; break;
    : switch (suit)
    : {
    : case clubs: cout <<char(5); break;
    : case :diamonds cout <<char(4); break;
    : case hearts: cout << char(3); break;
    : case spades: cout << char(6); break;
    : }
    : }
    :
    :
    : void main()
    : {
    : card deck [52];
    :
    : cout<<endl;
    : for(int j=0; j<52; j++)
    : {
    : int num =(j%13)+2; //cycles through 2 to 14, 4 times
    : Suit su = Suit(j/13); //cycles through 0 to 3, 13 times
    : deck[j].init(num,su); // set card
    :
    :
    : cout<<"
    Ordered deck:
    ";
    : for( j=0; j<52; j++) //display ordered deck
    : {
    : deck[j].display();
    : cout<<" ";
    : if(!(j+1) % 13)) //new line every 13 cards
    : cout<< endl;
    : }
    : randomize(); //seed random numbers generator
    : for(j=0; j<52; j++) //for each card in the deck
    : {
    : int k = random(52); // pick another card at random
    : card temp = deck[j]; //and swap them
    : deck[j] =deck[k];
    : deck[k] = temp;
    : }
    : cout<< "
    shuffled deck:
    ;
    : for(j=0; j<5; j++)
    : {
    : deck[j].display(); // display shuffled deck
    : cout<<" ";
    : if (!( (j+1) % 13 ))
    : cout<< endl;
    : }
    : getch(); //wait for keypress
    : } //end main
    :

  • Andre YoungAndre Young USAMember Posts: 0

    ___ ( http://forcoder.org ) free ebooks and video tutorials about | R, Python, Scratch, PL/SQL, C#, Objective-C, Ruby, Assembly, MATLAB, JavaScript, C++, Java, PHP, C, Swift, Perl, Visual Basic, Visual Basic .NET, Delphi, Go Ada, ABAP, COBOL, Alice, Clojure, FoxPro, ML, Julia, VBScript, Awk, D, LabVIEW, SAS, Scheme, Erlang, Crystal, Apex, Transact-SQL, Rust, Scala, Kotlin, Lua, Prolog, Logo, Hack, Fortran, Dart, F#, Bash, Lisp | _____

Sign In or Register to comment.