You will create two programs. The first one will use the data structure Stack and the other program will use the data structure Queue. Keep in mind that you should already know from your video and free textbook that Java uses a LinkedList integration for Queue. Stack Program Create a deck of cards using an array (Array size 15). Each card is an object. So you will have to create a Card class that has a value (1 - 10, Jack, Queen, King, Ace) and suit (clubs, diamonds, heart, spade). You will create a stack and randomly pick a card from the deck to put be pushed onto the stack. You will repeat this 5 times. Then you will take cards off the top of the stack (pop) and reveal the values of the cards in the output. As a challenge, you may have the user guess the value and suit of the card at the bottom of the stack. Queue Program There is a new concert coming to town. This concert is popular and has a long line. The line uses the data structure Queue. The people in the line are objects called Person. Create a Person class that has a first name, last name, and ticket number. Create 7 people and randomly add them to the line. Create 7 random ticket numbers. As each person is dequeued from the line, they are assigned a ticket number. Print each person being dequeued from the line (Fname, Lname, and ticket number). Submission Submit all .java files. Submit a PDF or Word document that contains the screenshots of the output.
You will create two programs. The first one will use the data structure Stack and the other program will use the data structure Queue. Keep in mind that you should already know from your video and free textbook that Java uses a LinkedList integration for Queue. Stack Program Create a deck of cards using an array (Array size 15). Each card is an object. So you will have to create a Card class that has a value (1 - 10, Jack, Queen, King, Ace) and suit (clubs, diamonds, heart, spade). You will create a stack and randomly pick a card from the deck to put be pushed onto the stack. You will repeat this 5 times. Then you will take cards off the top of the stack (pop) and reveal the values of the cards in the output. As a challenge, you may have the user guess the value and suit of the card at the bottom of the stack. Queue Program There is a new concert coming to town. This concert is popular and has a long line. The line uses the data structure Queue. The people in the line are objects called Person. Create a Person class that has a first name, last name, and ticket number. Create 7 people and randomly add them to the line. Create 7 random ticket numbers. As each person is dequeued from the line, they are assigned a ticket number. Print each person being dequeued from the line (Fname, Lname, and ticket number). Submission Submit all .java files. Submit a PDF or Word document that contains the screenshots of the output.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images