Objectives1 to practice defining classes using separate

Assignment Help JAVA Programming
Reference no: EM13351306

Objectives:

1. To practice defining classes using separate compilation.

2. To practice using classes, vectors, and pointers.

3. To gain experience using dynamic memory.

Scenario:  The owners of the most popular Las Vegas casinos were so impressed with your UCLA promotional interactive animated cartoon that they want to hire you to design a bunch of new electronic card games using C++.  Your first task in this project is to help their coding team finish modeling a playing card and a deck of playing cards as C++ objects.

   Directions:

 Create a Win 32 Console Application project called "Hw8" in your solution called "Homework" using Microsoft Visual Studio.  

 1. You are to implement the following Card class.

enum Suit {HEARTS, CLUBS, SPADES, DIAMONDS};

enum Rank {ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING};

 class Card{

   public:

          Card(Rank r, Suit s);

          Rank getRank()const;

          Suit getSuit()const;

          string toString()const;

   private:

    Suit suit;

    Rank rank;

};

 First place the code above in a header file Card.h and make sure it has include guards.  Then define the Card member functions in the implementation file Card.cpp. I provided the definition of Card's toString() member function below to help get you started:

 string Card::toString()const{

     string description = "";

     switch(rank) {

  case ACE:

    description += "Ace";

    break;

  case TWO:

    description += "Two";

    break;

        case THREE:

    description += "Three";

    break;

  case FOUR:

    description += "Four";

    break;

        case FIVE:

    description += "Five";

    break;

  case SIX:

    description += "Six";

    break;

        case SEVEN:

    description += "Seven";

    break;

  case EIGHT:

    description += "Eight";

    break;

  case NINE:

    description += "Nine";

    break;

        case TEN:

    description += "Ten";

    break;

  case JACK:

    description += "Jack";

    break;

  case QUEEN:

    description += "Queen";

    break;

  case KING:

    description += "King";

    break;

  }

   description += " of ";

   switch(suit) { 

  case HEARTS:

    description += "Hearts";

    break;

  case CLUBS:

                description += "Clubs";

    break;

  case SPADES:

    description += "Spades";

    break;

  case DIAMONDS:

                description += "Diamonds";

    break;

  }

  return description;

}

 Be sure to define the other Card member functions in the implementation file also.

 2. You are to implement the following class CardDeck which models a standard deck of 52 playing cards:

 class CardDeck  {

  public:

     CardDeck();   // default constructor

    ~CardDeck();  // destructor

      /* Returns the Card pointer at the back of the vector or NULL if the deck is empty. */

     Card* getTopCard();

      /* Prints each card, one per line, using the Card's toString() member function. 

     */

     void print()const;

      /* Shuffles the deck of cards by swapping two random elements of the deck.  */

  void shuffle();

     private:

      vector<Card*> deck;

       /* Swaps the contents of the elements of deck at the given   

         indices. */

      void swapCards(int index1, int index2);

};

 Be sure to put the code above in a header file called CardDeck.h with include guards and the appropriate include statements. The definitions of the CardDeck class member functions should go in the implementation file CardDeck.cpp Make sure the implementation file includes the CardDeck header file.

Reference no: EM13351306

Questions Cloud

1 a company is considering an expansion projectnbsp the : 1. a company is considering an expansion project.nbsp the companys cfo plans to calculate the projects npv by
1 describe how welfare creates work disincentives2 : 1. describe how welfare creates work disincentives.2. education is habitually used as an example of a positive
You have been tasked with building an organizational : you have been tasked with building an organizational structure for a new company that manufactures office equipment
Theme the eu and turkey scenarios to 2050 general : theme the eu and turkey scenarios to 2050 general guidelinesa. the eu and turkey can be seen in their long-term
Objectives1 to practice defining classes using separate : objectives1. to practice defining classes using separate compilation.2. to practice using classes vectors and
Leadership theoremchoose two of the ilf presentations and : leadership theoremchoose two of the ilf presentations and debate their lessons for leadership. you should use theory in
Questions1assess the techniques used by qinetiq for : questions1.assess the techniques used by qinetiq for improving business processes and evaluate the success of the
Evaluate the effectiveness of stms strategy of combining as : evaluate the effectiveness of stms strategy of combining as many existing initiatives as possible in order to simplify
1 briefly define the business2 how many businesses of this : 1 briefly define the business.2 how many businesses of this kind are there in the area? in the country?3 how easy is it

Reviews

Write a Review

JAVA Programming Questions & Answers

  Reverse the array, and find the largest element

find the max block of an array by splitting it into three parts: left, middle, right. And then reverse the array, and find the largest element.

  Determine java application on web and structure functions

Determine the Java application on Web and explain how program structure functions. Explain the application in as much detail as possible.

  Fixing errors in a java program

You coded the following on line ten of the class MyApplet.java:

  Display at least the waiting at each floor

From the 1st floor, the elevator can only go in one direction - up. And from the 12th floor the elevator can only go in one direction - down.

  Finding java code error

Indicate in the given code segment if an error occurs. If so, point to whether it is syntax, runtime or logic and how you would fix it.

  Determine product a inferior or normal good

Research illustrates that prices of related goods are given by Py = $5,900 and ; Pz = $90, while average income of individuals consuming this product is M = $55,000. Is X inferior or normal good?

  Evaluate the rtas resource requirements

Design and implement a set of classes and interfaces and use them to evaluate the RTA's resource requirements.

  This is a simulation of rolling dice actual results

this is a simulation of rolling dice. actual results approach theory only when the sample size is large. so we will

  Write a java program that will read a sequence of names

Write a java program that will read a sequence of names (first name followed by last name, separated by at least one space) from a text file and will 1) remove all duplicate names and 2) write the names (last name followed by a comma, followed by one..

  Compute the correct number of square feet needed

The Carpet House owner wants to put a carpet calculator on his website so that visitors can estimate the amount of carpet they will need to purchase.

  Write a java program

To become familiar with how infix expressions can be converted to postfix expressions.

  Accepts a scanner representing an input file

Write a method in JAVA called stripHtmlTags that accepts a Scanner representing an input file containing an HTML web page as its parameter, then reads that file and prints the file's text with all HTML tags removed. A tag is any text between the c..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd