For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2005 > Homework Help! Urgent!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Homework Help! Urgent!
xscarsofdesirex

2005-02-27, 8:59 pm

Probably a very simple program, but I am completely stumped.
Any help in coding (even hints) for this would be GREATLY
appreciated.
If you would like to contact me directly, my AIM is XscarsofdesireX.


Write a class called Card where each object represents a card. The
class should have three instance variables.
int myNum (stores a value 1 to 52)
String mySuit (suit of the card- to be determined by myNum)
String myValue (value of the card -1,....10,Jack, Queen, King, Ace)
(use integer division for mySuit and % for myValue)

The class should have a setValue() and setSuit(). They should be
called in the constructor.

Then write a class called DeckOfCards that holds 52 objects of type
cards. Write methods that will assign each card a different number 1
to 52, will shuffle the deck, will deal a card, and tell how many
cards are left.

Create a driver that will shuffle the deck, then pring out as many
cards as the user wants dealt from the top of the deck.


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Patricia Shanahan

2005-02-27, 8:59 pm

xscarsofdesirex wrote:

> Probably a very simple program, but I am completely stumped.
> Any help in coding (even hints) for this would be GREATLY
> appreciated.
> If you would like to contact me directly, my AIM is XscarsofdesireX.
>
>
> Write a class called Card where each object represents a card. The
> class should have three instance variables.
> int myNum (stores a value 1 to 52)
> String mySuit (suit of the card- to be determined by myNum)
> String myValue (value of the card -1,....10,Jack, Queen, King, Ace)
> (use integer division for mySuit and % for myValue)
>
> The class should have a setValue() and setSuit(). They should be
> called in the constructor.
>
> Then write a class called DeckOfCards that holds 52 objects of type
> cards. Write methods that will assign each card a different number 1
> to 52, will shuffle the deck, will deal a card, and tell how many
> cards are left.
>
> Create a driver that will shuffle the deck, then pring out as many
> cards as the user wants dealt from the top of the deck.
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com


I have a web page on how to get started, when stuck on a
programming assignment or project, at
http://home.earthlink.net/~patricia...n/beginner.html

Patricia

SMC

2005-02-28, 3:59 am

The description practically holds your hand through it. I'll strip out the
extraneous text practically leaving you with the skeleton of a solution.

<snip>
class Card {

int myNum // stores a value 1 to 52
String mySuit // suit of the card- to be determined by myNum String
myValue // value of the card -1,....10,Jack, Queen, King, Ace (use
integer division for mySuit and % for myValue)

setValue()

setSuit()

// constructor.

}

class DeckOfCards {

// holds 52 objects of type cards.

// methods ... (4 to implement)

// will assign each card a different number 1 to 52

// will shuffle the deck

// will deal a card

// tell how many cards are left.
}

> Create a driver that will shuffle the deck, then pring out as many cards
> as the user wants dealt from the top of the deck.


I'll say that the above sentence is probably badly worded/confusing. Just
create another class whose main() method creates a DeckOfCards object and
takes user input to decide how many times to call the "deal" method
belonging to the DeckOfCards object.

Break down the problem description to its basic elements and you at least
have a start.

--
Sean

"They have misunderestimated me" --George W. Bush
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com