DOC PREVIEW
FIU EEL 2880 - Documenting a Program for presentation

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Documenting a Programfor presentationFirst explain the problem to be solved and the model usedProblem solving:What is a deck of cards? How can cards be modeled?This card can be card 18 in the deck and is a Jack of ClubsThe card number is 18Clubs is the suitJack is the face valueProblem solving:How many cards?How many suits?How many face values?Suit values are0- Hearts, 1-Diamonds2- Clubs, 3-SpadesFace Values are0-Ace1-Two2-Three3-Four4-Five5-Six6-Seven7-Eight8-Nine9-Ten10-Jack11-Queen12-KingProblem Solving:So the card deck array will need a row for each cardand each card row will needelements for suit and face valuesProblem Solving:How many dimensions willCardDeck array require?Use an array to represent cardsFirst dimension:The element represents the card row numberEach array row is a cardHow large is this array dimension?CardDeck[??]How much information needed for each card?How many dimensions does the array need?CardDeck[??][??]Problem solving:Each card has a number for the card rowand elements for the cardsuit and face valuesHow many elements neededfor each card?Problem Solving:The first dimension: each element represents card row in deckThe second dimension represents card characteristic elements first element holds suit number of card second element holds face number of cardAccording to prior definition tableCard[18][0] = 2 (Clubs)Card[18][1] = 10(Jack)Card Row NumbersuitfaceCard# Suit # Face ValueRow# Column [0] Column [1]0 0 - Hearts 0 - Ace1 0 - Hearts 1 - Two2 0 - Hearts 2 - Three3 0 - Hearts 3- Four4 0 - Hearts 4 - Five5 0 - Hearts 5 - Six6 0 - Hearts 6 - Seven7 0 - Hearts 7 - Eight8 0 - Hearts 8 - Nine9 0 - Hearts 9 - Ten10 0 - Hearts 10 - Jack11 0 - Hearts 11 - Queen12 0 - Hearts 12 - King13 1 - Diamonds 0 - Ace14 1 - Diamonds 1 - Two15 1 - Diamonds 2 - Three16 1 - Diamonds 3- FourA multi-dimension arraycan be visualized as a table withRows being the first dimensionand Columns being the secondOverall ProgramStatement: What does it do?Process DiagramSequence stepsObjectsFunctionsFunctionsStatement: What does it do?Calling and return argumentsSequence stepsObjectsFunctionsWhat does the program do?:Creates and use a model for a deck of cards.The deck of cards is created and initializedThen deck of cards is shuffled and printed.Create Deck of cardsCreate Card DescriptionsInitialize Variables and ObjectsShuffle the deckSwap two CardsPrint out the deckGet a card valueInitialize the deckProcess DiagramSequence: main()●Declare:card deckcard text descriptions●Initialize:variablescard deck contents (function call)random number generator (function call)●Print out the card deck (function call)●Shuffle the deck (function call)●Print out the card deck (function call)Objects:●Card deck array●Card text descriptions ●variablesFunctions: ●Main function●Initialize deck●Print a card●Get card value●Shuffle the deck●Rand & SRand●Swap two cardsMainSrandInitDeckShuffleDeckPrintCardSwapCardsGetPlayValueProgram HierarchyInitialize the deck with card valuesCalling Arguments: card deckReturn Argument: noneSequence:Create variablesLoop through deckEach card row:Set the suit valueSet the face valueObjects:loop increment variableFunctions:noneFunction Name: InitDeckShuffle the card deckCalling Arguments: card deckReturn Argument: noneSequence:Create local variablesLoop through each card rowSwap that card and another random card row in deckObjects:loop increment variableSource and destination card variableFunctions needed:Swap two cardsFunction Name: ShuffleSwap two cards in deckCalling Arguments: deck of cards, card1, card2Return Argument:noneSequence:Create local variablesLoop to do card face & suit columnsset temporary value to card1set card1 value to card2set card2 to temporary valueObjects needed:loop increment variabletemporary variableFunctions needed:noneFunction Name: SwapCardsPrint a card suit and face valueCalling Arguments: card deck, card to printReturn Argument:noneSequence:Create local variablesretrieve suit & face value from rowget the play value of cardprint card informationObjects needed:local face, suit, play variablesFunctions needed:GetPlayValueFunction Name: PrintCardDetermine the play value of a cardCalling Arguments: deck of cards, card numberReturn Argument:play value of cardProcess List:Create local variablesretrieve suit & face value of card rowdetermine play value of cardreturn card valueObjects needed:local face, suit, play variablesFunctions needed:noneFunction Name:


View Full Document

FIU EEL 2880 - Documenting a Program for presentation

Download Documenting a Program for presentation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Documenting a Program for presentation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Documenting a Program for presentation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?