Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 Assignment Use CircularLinkedList.java as a starting point to make a new program that reads in a 'deck' of 28 numbers (from a file, from

image text in transcribedimage text in transcribed

5 Assignment Use CircularLinkedList.java as a starting point to make a new program that reads in a 'deck' of 28 numbers (from a file, from a command line, or an array, your choice), asks the user for one or more messages to decrypt, and decrypts them using the modified Solitaire algorithm described above. Note that if your program is decrypting multiple messages, all but the first should be decrypted using the deck as it exists after the decryption of the previous message. (The first uses the deck provided, of course.) 5.1 Why a Circular Linked List? We use Circular Linked List here for a few reasons Good practice solving and thinking for the upcoming exam. The wrap around nature of the Circular Linked List allows us to not worry about Steps 1 and 2. Linked Lists are ideal for these kinds of manipulations, as we can move entire sections of the list around much, much quicker than an ArrayList. For example, in step 3, we can split our deck into multiple smaller decks and recombine them very quickly. 5.2 Output Your output will be just the decrypted messages lists of characters without spaces or punctuation. The hard part of Solitaire is the generation of the keystream values. (They will be used to encrypt or decrypt our messages.) Here are the steps used in our variant of the algorithm, assuming that we start with a list of the values from 1-28 as described above. 1. Find the A joker (27). Swap Joker A with the card beneath (after it in the deck. This will effectively move the card down one position. (What if the joker is the last card in the deck? Imagine that the deck of cards is continuous; the card following the bottom card is the top card of the deck, and you'd just exchange them.)? 2. Find the B joker (28). Move Joker B two cards down by performing two exchanges. 3. Perform the triple cut. To do this, take all the cards above the first joker (the one closest to the top of the deck, A and B don't matter in this step) and swap it with all the cards below the second joker. 4. Remove the bottom card from the deck. Count down from the top card by a quantity of cards equal to the value of that bottom card. (If the bottom card is a joker, let its value be 27, regardless of which joker it is.) Take that group of cards and move them to the bottom of the deck. Return the bottom card to the bottom of the deck. 5. (Last step! Look at the top card's value (which is again 1-27, as it was in the previous step). Keep it at the top of the deck. Count down the deck by that many cards. Record the value of the NEXT card in the deck, but don't remove it from the deck. If that next card happens to be a joker, don't record anything. Leave the deck the way it is, and start again from the first step, repeating until that next card is not a joker. The value that you recorded in the last step is one value of the keystream, and will be in the range 1 -26, inclusive (to match with the number of letters in the alphabet). To generate another value, we take the deck as it is after the last step and repeat the algorithm. We need to generate as many keystream values as there are letters in the message being encrypted or decrypted. 5 Assignment Use CircularLinkedList.java as a starting point to make a new program that reads in a 'deck' of 28 numbers (from a file, from a command line, or an array, your choice), asks the user for one or more messages to decrypt, and decrypts them using the modified Solitaire algorithm described above. Note that if your program is decrypting multiple messages, all but the first should be decrypted using the deck as it exists after the decryption of the previous message. (The first uses the deck provided, of course.) 5.1 Why a Circular Linked List? We use Circular Linked List here for a few reasons Good practice solving and thinking for the upcoming exam. The wrap around nature of the Circular Linked List allows us to not worry about Steps 1 and 2. Linked Lists are ideal for these kinds of manipulations, as we can move entire sections of the list around much, much quicker than an ArrayList. For example, in step 3, we can split our deck into multiple smaller decks and recombine them very quickly. 5.2 Output Your output will be just the decrypted messages lists of characters without spaces or punctuation. The hard part of Solitaire is the generation of the keystream values. (They will be used to encrypt or decrypt our messages.) Here are the steps used in our variant of the algorithm, assuming that we start with a list of the values from 1-28 as described above. 1. Find the A joker (27). Swap Joker A with the card beneath (after it in the deck. This will effectively move the card down one position. (What if the joker is the last card in the deck? Imagine that the deck of cards is continuous; the card following the bottom card is the top card of the deck, and you'd just exchange them.)? 2. Find the B joker (28). Move Joker B two cards down by performing two exchanges. 3. Perform the triple cut. To do this, take all the cards above the first joker (the one closest to the top of the deck, A and B don't matter in this step) and swap it with all the cards below the second joker. 4. Remove the bottom card from the deck. Count down from the top card by a quantity of cards equal to the value of that bottom card. (If the bottom card is a joker, let its value be 27, regardless of which joker it is.) Take that group of cards and move them to the bottom of the deck. Return the bottom card to the bottom of the deck. 5. (Last step! Look at the top card's value (which is again 1-27, as it was in the previous step). Keep it at the top of the deck. Count down the deck by that many cards. Record the value of the NEXT card in the deck, but don't remove it from the deck. If that next card happens to be a joker, don't record anything. Leave the deck the way it is, and start again from the first step, repeating until that next card is not a joker. The value that you recorded in the last step is one value of the keystream, and will be in the range 1 -26, inclusive (to match with the number of letters in the alphabet). To generate another value, we take the deck as it is after the last step and repeat the algorithm. We need to generate as many keystream values as there are letters in the message being encrypted or decrypted

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

Can consultants replace outsourced activities? Why or why not?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

How was their resistance overcome?

Answered: 1 week ago