473,378 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

What codes to do next? Stuck!

3
Black Jack Project for C++ Programming school. Can't seem to move forward and what additional codes to use on Card.cpp.

Pseudo Code is for 'Card class'.
Constructor - initialize the member variables using the member initializer list in the constructor. The body of the constructor remains empty. END FUNCTION

Function getValue
Return the value of the card if the card is facing up. Otherwise return 0. Note: The king, queen and jack should also return a value 10. END FUNCTION

Function flip()
Flips a card. Face up becomes face down, and face down becomes face up. END FUNCTION


Here's what I have so far:

Card.h

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. #ifndef CARD_H
  7. #define CARD_H
  8.  
  9. class Card
  10. {
  11. private:
  12.     bool isFaceUp();
  13.  
  14. public:
  15.     Card(in rank: RANK = ACE, in suit: RANK = SPADES, in isUP:bool = true);
  16.     enum RANK;
  17.     enum SUIT;
  18.     int getValue();
  19.     void flip();
  20. protected:
  21.     RANK rank;
  22.     SUIT suit;
  23. };
  24.  
  25. #endif
  26.  
May 7 '13 #1
1 1393
weaknessforcats
9,208 Expert Mod 8TB
You are doing this backwards.

First you write the pseudo-code for the functions and then you determine what data has to be in the class for the functon to work.

All class data is private. Member functions are public.

Do not write protected code until you know what protected means. In a 20-year career you might get to do this once.

I further suggest you write the main() first so you know what has to be created. That gives you the class. Then calling member functions in main()is the signal to add them to the class. The idea is you end up with the minimum amoount of data and code for yur class.

Functions should only return values if they are to be used as RVALs. Personally, I only return success/fail codes and use a pointer argument to send a value to the calling function.

There appears to be a bug in your specs. The getValue function is returning the value of the card if the card is face up otherwise it returns zero. Ths confuses data (the value) with the state (face up). If you ever need to know the value of a face down card the code breaks down. Never "timeshare" data with some kind of code.

You never write pseudo-code for constructors, destructors, operators, etc. since these are "implementation details" of using C++. You only p-code the problem logic.

Finally, p-code does not mean to write the function in C++, or the class for that matter. It means to wriet the logic. You might read up on how to use CRC cards.
May 7 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jim Douglas | last post by:
With .NET becoming the right tool to use now what do you think is going to be the next great development technology? Thanks! -- Jim Douglas www.genesis-software.com
3
by: Mlaen | last post by:
My goal is to learn DirectX & OpenGL programming but I'm not in hurry and just haf finished the basic... My question is what should I learn next...Perhaps read some book about OOP programing or...
3
by: Frankie | last post by:
What would be an efficient way to retrieve two values from a stored procedure via ADO.NET? I understand ADO.NET's ExecuteScalar() method returns one value. I need two values returned, and...
1
by: Marni | last post by:
I have this line of code Private As IntPtr What does mean? It is unsearchable in both google and msdn due to the square brackets
1
by: JohnR | last post by:
I normally validate the data in a control in that controls validating event. I also normally have a Cancel button on each form which does a RejectChanges to reset any unsaved data on the form. ...
6
by: Comrad80 | last post by:
Everyone hi, Look at this: www.play-sex-game.com They have free demo. I really like this. What do you think will be the next? Virtual girls, kids, life?
2
by: Joe | last post by:
L International Reveals Plans for High-Tech Next-Generation Laptop Computer Systems L International Computers Inc. "L" renowned manufacturer of high-performance computers and personal/business...
7
by: JoeP | last post by:
Hi All, What codes grab the IP address? Thanks, Joe
0
by: king | last post by:
www.hrconsultant.tk
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.