Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey please i need help to write the MATLAB Program: You get a summer job as a software engineer. Your boss wants you to work

Hey please i need help to write the MATLAB Program:

You get a summer job as a software engineer. Your boss wants you to work on a project to create software for playing card games online. He does not want you to complete the whole software but work on only pieces of it. He calls you into his o?ce and hands you a piece of paper showing the pseudocode of what he wants you to do Goal is to create a program which asks a single user how many cards he/she wants and then displays the cards to the screen in a specific format.

Pseudocode: 1. ask a user how many cards he/she wants

2. initialize a deck of cards (52 cards, not shuffled)

3. shuffle the deck of cards

4. give the user his/her cards

5. display the cards to the screen

He warns that the whole code should only consist of 1 program and 6 functions. He provides you with a description of what the functions MUST input and MUST output (function input not keyboard input). He also warns that the cards must look like the ones shown.

Function 01: filename: init_deck.m purpose: This function creates a deck of cards that are not sorted. input: 0 variables output: 1 variable NAME UNITS TYPE SIZE DESCRIPTION d [n/a] struct (1,52) structure containing card info. d.suit [n/a] char (1,M) suit of card d.name [n/a] char (1,N) name of card (9,10, J, Q, K) d.val [n/a] float (1,1) value of card (9,10,11,12,13) hint: Take an A as having a value of 1. Function 02: filename: shuffle_deck.m purpose: This function shuffles a deck of cards note: This function uses the randomize_order function input: 1 variable NAME UNITS TYPE SIZE DESCRIPTION d [n/a] struct (1,52) structure containing ordered deck. output 1 variable NAME UNITS TYPE SIZE DESCRIPTION d [n/a] struct (1,52) structure containing shuffled deck. hint: I would randomize the vectors indicies

Function 03: filename: randomize_order.m purpose: This function randomizes the order of a vector v input: 1 variable NAME UNITS TYPE SIZE DESCRIPTION vin [n/a] float (1,52) a vector of numbers output: 1 variable NAME UNITS TYPE SIZE DESCRIPTION vout [n/a] float (1,52) the original array but now in a random order hint: I have a vector of size n. Choose a random element from that array and put it into a new vector. Delete that element from the array. Repeat. A = [ 4 3 9 ]; B(1)=A(2); A(2)=[ ]; A

Function 04: filename: dealcards.m purpose: This function deals n cards to the player p from the deck d input: 2 variables NAME UNITS TYPE SIZE DESCRIPTION d [n/a] struct (1,N) structure containing shuffled deck. n [n/a] float (1,1) number of cards the player wants output 2 variable d [n/a] struct (1,M) structure containing shuffled deck. p [n/a] struct (1,n) structure containing players cards. p.suit [n/a] char (1,P) suit of card p.name [n/a] char (1,Q) name of card (9,10, J, Q, K) p.val [n/a] float (1,1) value of card (9,10,11,12,13) hint: caution. If the deck only has 2 cards, then I cant get 4 cards from it. If this happens then you need to grab another deck of cards and shuffle it. Function 05: filename: display_cards.m purpose: This function displays the users cards to the screen note: This functions uses the setup_display_card function input: 1 variable NAME UNITS TYPE SIZE DESCRIPTION p [n/a] struct (1,n) structure containing players cards. output: 0 variables hint: remember to show the cards side-by-side (see example output) -

Function 06: filename: setup_display_card.m purpose: This function sets up a single card to be displayed given the cards suit and name input: 2 variables NAME UNITS TYPE SIZE DESCRIPTION value [n/a] float (1,1) value of card (ex. 11) suit [n/a] char (1,B) suit of card (ex. hearts) output: 1 variable NAME UNITS TYPE SIZE DESCRIPTION c [n/a] struct (1,1) structure containing card c.card [n/a] char (11,13) string containing card hint: see card format on the last page.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions