Poker Forum

Over 1,246,000 Posts!

Subscribe to FTR web feed
Already Registered?      Username:    Password:   Remember      Forgot Password
  >    > 

anyone know C++

  
 
LinkBack Thread Tools Display Modes
badandy519
Old 05-29-2006, 02:07 AM     Post subject: anyone know C++ #1 (permalink)  
badandy519's Avatar
Straight

Join Date: Aug 2005
Location: mckinney, tx
Posts: 223
badandy519
Send a message via AIM to badandy519 Send a message via MSN to badandy519 Send a message via Yahoo to badandy519
A friend of mine needs this done....

A point is a an X and Y coordinate pair (2 integers). Design a class that stores the data for a point and has the following methods a default constructor, a constructor that takes an x and y coordinates, set x coordinate, set y coordinate, print the point data to the screen, return the x coordinate, return the y coordinate . Write a test program to test this class and all its methods.
Reply With Quote
Join the FTR Poker Forum to disable these banners and start posting!
Old 05-29-2006, 02:08 AM #2 (permalink)  
Guest

Posts: n/a
A(a) + B(b) = C(c)
Reply With Quote
Knytestorme
Old 05-29-2006, 02:12 AM #3 (permalink)  
Knytestorme's Avatar
Flush

Join Date: May 2005
Location: Australia
Posts: 562
Knytestorme
Send a message via ICQ to Knytestorme
When exactly is his homework assignment due?
Reply With Quote
badandy519
Old 05-29-2006, 02:17 AM #4 (permalink)  
badandy519's Avatar
Straight

Join Date: Aug 2005
Location: mckinney, tx
Posts: 223
badandy519
Send a message via AIM to badandy519 Send a message via MSN to badandy519 Send a message via Yahoo to badandy519
lol, it's a "her" and it's due at midnight
Reply With Quote
Knytestorme
Old 05-29-2006, 02:27 AM #5 (permalink)  
Knytestorme's Avatar
Flush

Join Date: May 2005
Location: Australia
Posts: 562
Knytestorme
Send a message via ICQ to Knytestorme
Well if I wasn't at work I'd consider doing it just for the hell of it but if I did it here they could claim copyright and ownership of the code and sue her for copyright infringement and plagerism so...

It's not an incredibly hard assignment though, is probably about 30 minutes coding with a c++ boox in front of her if she understands the concept of classes, I mean there isn't even any real need to worry about pointers which is usually half the problem for C++ newbies.
Reply With Quote
Pyroxene
Old 05-29-2006, 02:32 AM     Post subject: Re: anyone know C++ #6 (permalink)  
Straight

Join Date: Dec 2004
Posts: 236
Pyroxene
Quote:
Originally Posted by badandy519
A friend of mine needs this done....

A point is a an X and Y coordinate pair (2 integers). Design a class that stores the data for a point and has the following methods a default constructor, a constructor that takes an x and y coordinates, set x coordinate, set y coordinate, print the point data to the screen, return the x coordinate, return the y coordinate . Write a test program to test this class and all its methods.
I have not done any C++ in several years. Switched to Java and forgot everything. It will be something like this:

public class Point {
int x;
int y;

public Point()
{
x = 0;
y = 0;
}

public Point ( int initX, int initY )
{
x = initX;
y = initY;
}

public void setX( int newX )
{
x = newX;
}

public void setY( int newY )
{
y = newY;
}

public void printPoint()
{
printf( "X = %d, Y = %d\n", x, y );
}

public int getX( )
{
return x;
}

public int getY()
{
return y;
}

};

That should get you started, I may have some syntax problems. You might consider using cout instead of printf in the printPoint method, but that is up to how the professor likes it. cout is great from an academic point of view, but printf is what gets used in the real world. Even Java added a multi-argument printf-like method in 1.5.

Other things, I specifically picked parameters names to not mask the member variable names. You can rename them to mask and use the this keyword. Again, shoot for what the professor would want.
Pyroxene
 
Reply With Quote
Knytestorme
Old 05-29-2006, 02:37 AM #7 (permalink)  
Knytestorme's Avatar
Flush

Join Date: May 2005
Location: Australia
Posts: 562
Knytestorme
Send a message via ICQ to Knytestorme
Yeah, that's about it really and anyone with understanding should be able to make the necessary adjustments and write the testcase program for that class.

Only changes I would make to the formating would be along the lines of

#include <iostream>
using namespace std;

class CPoint {
int x, y;
public:
void Point;
void Point ( int, int );
void setX( int );
void setY( int );
void printPoint();
int getX();
int getY();
void ~Point();
};

and then your methods after this, just allows you to get rid of the public keyword in front of each method.
Reply With Quote
Pyroxene
Old 05-29-2006, 02:46 AM #8 (permalink)  
Straight

Join Date: Dec 2004
Posts: 236
Pyroxene
Quote:
Originally Posted by Knytestorme
void ~Point();
Forgot about the destructor, my time in Java is showing However, would this class need an explicit destructor or copy constructor?
Pyroxene
 
Reply With Quote
Knytestorme
Old 05-29-2006, 02:54 AM #9 (permalink)  
Knytestorme's Avatar
Flush

Join Date: May 2005
Location: Australia
Posts: 562
Knytestorme
Send a message via ICQ to Knytestorme
depending on how it was being used but I have a fondness for destructors just because it makes it easier to remember and you get in the practise of just auto-inserting them.

For instance if it was used to create objects for a partical emitter class then I would most likely use a destructor class but it also comes down to the environment it is being used in (eg OS, Memory, etc) so to use a poker phrase in this case...it depends
Reply With Quote
bigred
Old 05-29-2006, 05:06 AM #10 (permalink)  
bigred's Avatar
PROFESSIONAL TROLL

Join Date: Sep 2004
Location: Nest of Douchebags
Posts: 2,184
bigred is a name known to allbigred is a name known to allbigred is a name known to allbigred is a name known to allbigred is a name known to allbigred is a name known to all
ALL YOUR BASE ARE BELONG TO US
LOL OPERATIONS
 
Reply With Quote
Knytestorme
Old 05-29-2006, 05:22 AM #11 (permalink)  
Knytestorme's Avatar
Flush

Join Date: May 2005
Location: Australia
Posts: 562
Knytestorme
Send a message via ICQ to Knytestorme
Move Zig, Move Zig
Send up every Zig
Reply With Quote
Reply
Latest Poker News
KoRnholio Old 05-26-2012, 03:08 PM    Australia Legalized Online Poker coming up in next 6 to 12 Months
According to an email sent out by Mark Bryan, a gaming analyst at Merrill Lynch, the Australian government plans to legalize online poker sometime in the next six to 12 months. This move will coincide ...

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:47 AM.


FTR Testimonials

All content
© FlopTurnRiver.com
Advertising  |   Partners  |   Testimonials  |   T&C  |   Contact Us  |   FTR News & Press  |   Site Map  |   Search FTR

Full Tilt  |   Titan Poker  |   UltimateBet  |   Poker Stars  |   Ladbrokes Bonus  |   Sportsbook  |   Cake Poker  

Play Texas Holdem Online, Online Texas Holdem Strategy, & Poker Forum
This is not a gambling website.