Jame Brown

Greenhorn
+ Follow
since Mar 18, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jame Brown

I am reviewing for a test and have am not sure about a question(sure more to come later)

For the question(s) below, consider the following class definition:

public class AClass
{
protected int x;
protected int y;

public AClass(int a, int b)
{
x = a;
y = b;
}

public int addEm( )
{
return x + y;
}

public void changeEm( )
{
x++;
y--;
}

public String toString( )
{
return "" + x + " " + y;
}
}

4) Consider that you want to extend AClass to BClass. BClass will have a third int instance data, z. Which of the following would best define BClass' constructor?
A) public BClass(int a, int b, int c)
{
super(a, b, c);
}
B) public BClass(int a, int b, int c)
{
x = a;
y = b;
z = c;
}
C) public BClass(int a, int b, int c)
{
z = c;
}
D) public BClass(int a, int b, int c)
{
super(a, b);
z = c;
}
E) public BClass(int a, int b, int c)
{
super( );
}

I think it is D but I could be wrong(probably am lol) I think this because of inheritance I figure since a,b don't change from A(well I think they don't) so why not call them from the superclass and then add the 3rd one.
18 years ago
So you think that Card is not the main class that is used to test it?

I also have questions about what you wrote:


First from the top why is it private? and why is it Private Rank myRank. ARe you getting the object Rank from enum types? and why did you name it myRank?

With this:

public Card(Rank rank, Suit suit)
{
//...
}

So your taking in 2 parmaters in right? 1 from rank and other from suit. So I am not sure though what I should add in it should I have an array list in it adding each paramter passed into the list? but then how do I get them all in? would I need some sort of loop or something like that?

Well thats where I am stuck I have not even attempted to look at the other hints you given me.
[ March 18, 2006: Message edited by: Jame Brown ]
18 years ago
I been thinking and I am wondering if this would work and how to go about doing it.

with the enum types right to keep that as if and add a arraylist to it. Like since a array list can grow to any length would this not be perfect to combine them all?

Like I was thinking of doing something like this

1st: Make the enum type Rank(holds: ace, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king)
2nd: Make the enum type Suit(holds: Hearts,Spades,Clubs,Diamonds)
3rd: Make an arrayList called deck
4th: throw that in a loop and have the loop add each card to this array by using the enum types. So like the loop would look something like this

Loop:
So the loop would basicly go through and add everything in Rank with incrmenting each time to the next one from ace to two etc, At the same time Suit would be adding suit type to the end of each card.

Once Rank would go through once it would start all over again and suit would move to the next one in the enum so from Hearts to Spades.

Problems:

I have no Idea how to actually make this work I never done anything like this where I am looping and changing the enum type by doing this. I also would not know how to make it start over again and change the suit after every 13 times.

Once I would have this I think I could use the array list in the random shuffle method and that would work?
18 years ago
I need to make a 3 classes that do this:

Classes: Deck-Of-Cards, Card, Shuffle-Deck

- Deck-Of-Cards that store 52 objects of the Card Class
- Shuffle-Deck (shuffles the deck,deals a card from the deck,keeps track how many cards are left in the deck)
- Card I guess is the driver class it really does not give me to much info on it.

It says that the Card class was from chapter 4 in my book but I can't find it anywhere expect as a project that we never did. And all it wanted was one class called card that represents a standard playing deck and deals like 5 cards out at random.

So I started to work on DeckOfCards first to hold the 52 objects so I thought of puting them as enum types in.

so I have it like this:


So to me I think thats all I need to do to hold in deck-of-cards since I think that holds the 52 to objects.

So then I moved to shuffle-Deck and did this:



as you can see not much since I am unable to get past a couple things like how do I shuffle this deck? I was going to use a random but problems I can see I will face is first how do I shuffle them as a whole? Like right now there are 2 enum types(Rank and Suit) how do I combine them together so that it will shuffle all 52 cards as a whole and still know that they belong to different suits.

So I need help and go from there.

*Deck-Of-Cards -- This is not a mistake I put those dashes on purpose in hopes to make it a bit harder to find on the search engine since I am sure many ppl will have trouble with this and will be looking for the answers..... So I don't them to just copy my work that I been working hard on....
18 years ago