Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 8th, 2006, 9:43 PM   #11
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
This is the output I'm getting:

Queen of spades is dealt with 51 cards left.
Seven of spades is dealt with 50 cards left.
Six of spades is dealt with 49 cards left.
Four of diamonds is dealt with 48 cards left.
Ace of spades is dealt with 47 cards left.
Seven of diamonds is dealt with 46 cards left.
Five of spades is dealt with 45 cards left.
Queen of diamonds is dealt with 44 cards left.
Jack of hearts is dealt with 43 cards left.
Seven of clubs is dealt with 42 cards left.
Three of spades is dealt with 41 cards left.
Jack of spades is dealt with 40 cards left.
King of clubs is dealt with 39 cards left.
Eight of clubs is dealt with 38 cards left.
Two of spades is dealt with 37 cards left.
King of spades is dealt with 36 cards left.
Ten of spades is dealt with 35 cards left.
Two of hearts is dealt with 34 cards left.
Eight of spades is dealt with 33 cards left.
Two of clubs is dealt with 32 cards left.
Nine of hearts is dealt with 31 cards left.
Six of clubs is dealt with 30 cards left.
Three of clubs is dealt with 29 cards left.
King of hearts is dealt with 28 cards left.
Nine of clubs is dealt with 27 cards left.
Ace of diamonds is dealt with 26 cards left.
Queen of clubs is dealt with 25 cards left.
Three of diamonds is dealt with 24 cards left.
Seven of hearts is dealt with 23 cards left.
Ten of diamonds is dealt with 22 cards left.
Jack of diamonds is dealt with 21 cards left.
Five of diamonds is dealt with 20 cards left.
Two of diamonds is dealt with 19 cards left.
Five of clubs is dealt with 18 cards left.
Ace of clubs is dealt with 17 cards left.
Six of hearts is dealt with 16 cards left.
Jack of clubs is dealt with 15 cards left.
Queen of hearts is dealt with 14 cards left.
Five of hearts is dealt with 13 cards left.
Nine of diamonds is dealt with 12 cards left.
Nine of spades is dealt with 11 cards left.
Four of clubs is dealt with 10 cards left.
Six of diamonds is dealt with 9 cards left.
Ten of clubs is dealt with 8 cards left.
Eight of diamonds is dealt with 7 cards left.
Ace of hearts is dealt with 6 cards left.
Ten of hearts is dealt with 5 cards left.
Four of hearts is dealt with 4 cards left.
Four of spades is dealt with 3 cards left.
King of diamonds is dealt with 2 cards left.
Eight of hearts is dealt with 1 cards left.
Three of hearts is dealt with 0 cards left.

Also, in the toString() if you want to clean it up a bit and not use all those if-else statements, you could use two instances of TreeMap or two parallell arrays (I think that's what they're called) and the code would be a bit neater. It was just easier for me to copy and paste, though, so that's why I'm using the if-else statements in case you were wondering.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jan 8th, 2006, 9:59 PM   #12
alcdotcom
Programmer
 
Join Date: Jan 2006
Location: Dallas, TX
Posts: 49
Rep Power: 0 alcdotcom is on a distinguished road
Quote:
Originally Posted by Mjordan2nd
An ArrayList will not take any of the primitive data types. You're going to have to use the Integer class.
Whoa - sorry to back up on you guys, but I have to interject here. An ArrayList will take primitive values. I pasted the code in from his original post to find out what the problem was and the only issue I had was with the cs1.Keyboard class. I created a Scanner
Scanner input = new Scanner( System.in );
and replaced
value = Keyboard.readInt();
with
value = input.nextInt();
and it worked fine. I'm not sure where your error was coming from.

ArrayList's will take ints, but they are implicitly converted to Integers. This is called autoboxing. Anytime you pass a priitive value to an ArrayList, it will box it into the corresponding object pair (int-Integer, float-Float, boolean-Boolean, etc). If you want to specify a particular type, you can do so (in jdk 1.5+) by using generics. So an ArrayList that takes int or Integer values would look like this:
ArralyList<Integer> list = new ArrayList<Integer>();
Wen you use generics, the parameter between the angle brackets does have to be a non-priitive, but you can still pass in primitive types (they'll be auto-boxed).
alcdotcom is offline   Reply With Quote
Old Jan 8th, 2006, 10:00 PM   #13
alcdotcom
Programmer
 
Join Date: Jan 2006
Location: Dallas, TX
Posts: 49
Rep Power: 0 alcdotcom is on a distinguished road
Quote:
Originally Posted by Mjordan2nd
if(list.size()==0)
Or you could just use
list.isEmpty()
alcdotcom is offline   Reply With Quote
Old Jan 8th, 2006, 10:07 PM   #14
alcdotcom
Programmer
 
Join Date: Jan 2006
Location: Dallas, TX
Posts: 49
Rep Power: 0 alcdotcom is on a distinguished road
You might also consider creating enum types for the rank of a card and the suit of a card.
alcdotcom is offline   Reply With Quote
Old Jan 8th, 2006, 10:29 PM   #15
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Quote:
Originally Posted by alcdotcom
Wen you use generics, the parameter between the angle brackets does have to be a non-priitive, but you can still pass in primitive types (they'll be auto-boxed).
Heh. Didn't know that. I stand corrected.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jan 9th, 2006, 5:07 PM   #16
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Sorry if my ways seem unusual its just I have not been taught how to use "Scanners" thats all.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old Jan 10th, 2006, 5:14 PM   #17
alcdotcom
Programmer
 
Join Date: Jan 2006
Location: Dallas, TX
Posts: 49
Rep Power: 0 alcdotcom is on a distinguished road
Quote:
Originally Posted by crawforddavid2006
Sorry if my ways seem unusual its just I have not been taught how to use "Scanners" thats all.
No, I'm sure your class is fine. I just didn't have access to it, so I used Scanner as a quick keyboard input method.
__________________
Java Blog
alcdotcom is offline   Reply With Quote
Old Jan 10th, 2006, 6:37 PM   #18
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
From now on I will put a link to the site that you can get that at as soon as i find that site again
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC