subject

Help pls The first class:

package assignment2;

import java. util. Random;

public class Deck {

public static String[] suitsInOrder = {"clubs", "diamonds", "hearts", "spades"};

public static Random gen = new Random();

public int numOfCards; // contains the total number of cards in the deck

public Card head; // contains a pointer to the card on the top of the deck

/*

* TODO: Initializes a Deck object using the inputs provided

*/

public Deck(int numOfCardsPerSuit, int numOfSuits) {

/* ADD CODE HERE */

}

/*

* TODO: Implements a copy constructor for Deck using Card. getCopy().

* This method runs in O(n), where n is the number of cards in d.

*/

public Deck(Deck d) {

/* ADD CODE HERE */

}

/*

* For testing purposes we need a default constructor.

*/

public Deck() {}

/*

* TODO: Adds the specified card at the bottom of the deck. This

* method runs in $O(1)$.

*/

public void addCard(Card c) {

/* ADD CODE HERE */

}

/*

* TODO: Shuffles the deck using the algorithm described in the pdf.

* This method runs in O(n) and uses O(n) space, where n is the total

* number of cards in the deck.

*/

public void shuffle() {

/* ADD CODE HERE */

}

/*

* TODO: Returns a reference to the joker with the specified color in

* the deck. This method runs in O(n), where n is the total number of

* cards in the deck.

*/

public Joker locateJoker(String color) {

/* ADD CODE HERE */

return null;

}

/*

* TODO: Moved the specified Card, p positions down the deck. You can

* assume that the input Card does belong to the deck (hence the deck is

* not empty). This method runs in O(p).

*/

public void moveCard(Card c, int p) {

/* ADD CODE HERE */

}

/*

* TODO: Performs a triple cut on the deck using the two input cards. You

* can assume that the input cards belong to the deck and the first one is

* nearest to the top of the deck. This method runs in O(1)

*/

public void tripleCut(Card firstCard, Card secondCard) {

/* ADD CODE HERE */

}

/*

* TODO: Performs a count cut on the deck. Note that if the value of the

* bottom card is equal to a multiple of the number of cards in the deck,

* then the method should not do anything. This method runs in O(n).

*/

public void countCut() {

/* ADD CODE HERE */

}

/*

* TODO: Returns the card that can be found by looking at the value of the

* card on the top of the deck, and counting down that many cards. If the

* card found is a Joker, then the method returns null, otherwise it returns

* the Card found. This method runs in O(n).

*/

public Card lookUpCard() {

/* ADD CODE HERE */

return null;

}

/*

* TODO: Uses the Solitaire algorithm to generate one value for the keystream

* using this deck. This method runs in O(n).

*/

public int generateNextKeystreamValue() {

/* ADD CODE HERE */

return 0;

}

public abstract class Card {

public Card next;

public Card prev;

public abstract Card getCopy();

public abstract int getValue();

}

public class PlayingCard extends Card {

public String suit;

public int rank;

public PlayingCard(String s, int r) {

this. suit = s. toLowerCase();

this. rank = r;

}

public String toString() {

String info = "";

if (this. rank == 1) {

//info += "Ace";

info += "A";

} else if (this. rank > 10) {

String[] cards = {"Jack", "Queen", "King"};

//info += cards[this. rank - 11];

info += cards[this. rank - 11].charAt(0);

} else {

info += this. rank;

}

//info += " of " + this. suit;

info = (info + this. suit. charAt(0)).toUpperCase();

return info;

}

public PlayingCard getCopy() {

return new PlayingCard(this. suit, this. rank);

}

public int getValue() {

int i;

for (i = 0; i < suitsInOrder. length; i++) {

if (this. suit. equals(suitsInOrder[i]))

break;

}

return this. rank + 13*i;

}

}

public class Joker extends Card{

public String redOrBlack;

public Joker(String c) {

if (!c. equalsIgnoreCase("red") && !c. equalsIgnoreCase("black"))

throw new IllegalArgumentException("Jokers can only be red or black");

this. redOrBlack = c. toLowerCase();

}

public String toString() {

//return this. redOrBlack + " Joker";

return (this. redOrBlack. charAt(0) + "J").toUpperCase();

}

public Joker getCopy() {

return new Joker(this. redOrBlack);

}

public int getValue() {

return numOfCards - 1;

}

public String getColor() {

return this. redOrBlack;

}

}

}

Second class:

package assignment2;

public class SolitaireCipher {

public Deck key;

public SolitaireCipher (Deck key) {

this. key = new Deck(key); // deep copy of the deck

}

/*

* TODO: Generates a keystream of the given size

*/

public int[] getKeystream(int size) {

/* ADD CODE HERE */

return null;

}

/*

* TODO: Encodes the input message using the algorithm described in the pdf.

*/

public String encode(String msg) {

/* ADD CODE HERE */

return null;

}

/*

* TODO: Decodes the input message using the algorithm described in the pdf.

*/

public String decode(String msg) {

/* ADD CODE HERE */

return null;

}

}


Help pls

The first class:package assignment2;import java.util.Random;public class Deck {public st

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
Martha is a healer, a healthcare provider, and an experienced nurse. she wants to share her daily experiences, as well as her 12 years of work knowledge, with people who may be interested in health and healing. which mode of internet communication can martha use?
Answers: 3
question
Computers and Technology, 22.06.2019 20:10
Assume that minutes is an int variable whose value is 0 or positive. write an expression whose value is "undercooked" or "soft-boiled" or "medium-boiled" or "hard-boiled" or "overcooked" based on the value of minutes. in particular: if the value of minutes is less than 2 the expression's value is "undercooked"; 2-4 would be a "soft-boiled", 5-7 would be "medium-boiled", 8-11 would be "hard-boiled" and 12 or more would be a "overcooked".
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u.s. 483 (1954). b. international shoe co. v. washington, 326 u.s. 310 (1945) c. haynes v. gore, 531 u.s. 98 (2000). d. international shoe co. v. washington, 14 u.s. code 336.
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Write the pseudo code for this problem based on what you learned from the video. the purpose is to design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. the conversion formula is as follows: miles = kilometers x 0.6214
Answers: 3
You know the right answer?
Help pls The first class:

package assignment2;

import java. util. Random;
Questions
question
Biology, 28.10.2020 01:00
question
Biology, 28.10.2020 01:00
question
Mathematics, 28.10.2020 01:00
question
Advanced Placement (AP), 28.10.2020 01:00
Questions on the website: 13722362