Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
breaking an array up? 0o
Author Message
SpaceDude

Posted: Mon Jun 07, 2004 2:14 pm   Post subject: breaking an array up? 0o

lol
hmm ok lets say this is for a card game ok?
so i make one array of 52
and then i want to split the array into 4 parts cuz there is 4 suits for the deck, and i want to split them in different colours, like red for diamond, purple for club, pink for hearts and black for spades, so how would i do it?

cuz i tried this way and it wouldn't work lol...

var Deck : array 1 .. 52 of int

%Diamonds
color (3)
Deck (1) := Ace
Deck (2) := 2
Deck (3) := 3
Deck (4) := 4
Deck (5) := 5
Deck (6) := 6
Deck (7) := 7
Deck (8) := 8
Deck (9) := 9
Deck (10) := 10
Deck (11) := JACK
Deck (12) := QUEN
Deck (13) := KING

%Clubs
color (5)
Deck (14) := Ace
Deck (15) := 2
Deck (16) := 3
Deck (17) := 4
Deck (18) := 5
Deck (19) := 6
Deck (20) := 7
Deck (21) := 8
Deck (22) := 9
Deck (23) := 10
Deck (24) := JACK
Deck (25) := QUEN
Deck (26) := KING

~~~
and so forth, so hmm is there a easier way to break this 52 array into 4 pieces easier? and can keep the colour?

thanks

Mazer

Posted: Mon Jun 07, 2004 2:43 pm   Post subject: (No subject)

 code: var Deck : array 1 .. 52 of string for i : 0 .. 3     Deck (i * 13 + 1) := "Ace"     for j : 2 .. 10         Deck (i * 13 + j) := intstr (j)     end for     Deck (i * 13 + 11) := "Jack"     Deck (i * 13 + 12) := "Queen"     Deck (i * 13 + 13) := "King" end for

EDIT: Hm... perhaps that wasn't what you wanted.
Well, just remember that every 13 cards is a different suit. So, 1-13 spades, 13-26 clubs, etc.
SpaceDude

Posted: Tue Jun 08, 2004 2:40 am   Post subject: (No subject)

ic thanks, i guess i know how to do it now
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: