40 likes | 48 Views
Bingo Example: Design (Print Card Algorithm). J. Michael Moore CSCE 121. Design. Console constrains output to characters only. Use a 2D (2 dimensional) homogeneous compound data structure that we can index into (e.g. an array or vector)
E N D
Bingo Example:Design(Print Card Algorithm) J. Michael Moore CSCE 121
Design • Console constrains output to characters only. • Use a 2D (2 dimensional) homogeneous compound data structure that we can index into (e.g. an array or vector) • Recall that most homogeneous compound data structures in computers have zero based indexes.
Design • We want to store numbers, but how to represent the free spot? • Use a negative value • Largest number is 2 digits so use 2 places for all numbers • Space between each column • Console uses monospaced fonts so alignment works with just spaces • Note that if we prepend a space to the first column each column is 3 characters wide including the space in the front. • Example output B I N G O 5 29 42 52 68 14 17 38 60 75 7 22 F 49 62 13 28 33 46 63 3 27 32 54 73
Overall • Fill card with values (we’ll see later) • Print Column Labels (i.e. BINGO) • Print the values where each letter is right justified with 3 spaces • Print values (use row major order) • For each row (values 0-4) • For each col (values 0-4) • Output card[row][col] right justified with 3 spaces • New line