Design and implement a class calledRandomArray, which has an…
Question Answered step-by-step Design and implement a class calledRandomArray, which has an… Design and implement a class called RandomArray, which has an integer array. The constructor receives the size of the array to be allocated, then populates the array with random numbers from the range 0 through the size of the array. Methods are required that return the minimum value, maximum value, average value, and a String representation of the array values. Document your design with a UML Class diagram. Make a separate driver class that prompts the user for the sample size, then instantiates a RandomArray object of that size and outputs its contents and the minimum, maximum, and average values. Hint: Obviously the minimum and maximum values will be integers, but the average will need to allow decimals.Testing: Include the output for several different test runs of various sizes, that shows the array contents with its minimum, maximum, and average values. In Assignment 4, you created a Card class that represents a standard playing card. Use this to design and implement a class called DeckOfCards that stores 52 objects of the Card class using an array. Include methods to shuffle the deck, deal a card, return the number of cards left in the deck, and a toString to show the contents of the deck. The shuffle methods should assume a full deck. Document your design with a UML Class diagram. Make a separate driver class that first outputs the populated deck to prove it is complete, shuffles the deck, and then deals each card from a shuffled deck, displaying each card as it is dealt along with the number of cards left in the deck. Hint: The constructor for DeckOfCards should have nested for loops for the face values (1 to 13) within the suit values (1 to 4) calling the two parameter constructor. The shuffle method does not have to simulate how a deck is physically shuffled; you can achieve the same effect by repeatedly swapping pairs of cards chosen at random.Testing: Include two complete runs to demonstrate the random effect of shuffling. Design and implement a recursive program to determine and print up to the Nth line of Pascal’s Triangle, as shown below. Each interior value is the sum of the two values above it. Hint: You should use an array to hold the values for a given line.It is not necessary to format the output exactly as presented above.One recursive approach is:T(n, 0) = T(n, n) = 1T(n, d) = T(n – 1, d – 1) + T(n – 1, d) Assignment Marking CriteriaWeightingCorrectness of solution: Algorithm is implemented and produces correct results for the stated problem/6Testing: Submission of test exhibits to indicate the solution works for a range of cases (e.g. minimum and maximum inputs) and handles unexpected exceptions/3Comments and documentation: Source code contains comments that explain in plain English what the code is intended to doNote: Javadoc style is not required./3 Card lass created in Assignment 4 public class Card{ private int suit; private int face; //default constructor public Card() { suit = (int)(Math.random()*4) + 1; face = (int)(Math.random()*13) + 1; } //parameterized constructor public Card(int suit, int face) { if(suit<1 || suit>4) suit = 0; else this.suit = suit; if(face<1 || face>13) face = 0; else this.face = face; } /* Accessor methods */ //return face public int getFace() { return face; } //return suit public int getSuit() { return suit; } //return face in text public String getFaceText() { switch(face) { case 1: return “Ace”; case 2: return “Two”; case 3: return “Three”; case 4: return “Four”; case 5: return “Five”; case 6: return “Six”; case 7: return “Seven”; case 8: return “Eight”; case 9: return “Nine”; case 10: return “Ten”; case 11: return “Jack”; case 12: return “Queen”; case 13: return “King”; } return null; } //return suit in text public String getSuitText() { switch(suit) { case 1: return “Spades”; case 2: return “Hearts”; case 3: return “Diamonds”; case 4: return “Clubs”; } return null; } //return String public String toString() { return getFaceText() + ” of ” + getSuitText(); } /* Mutators methods */ //set face public void setFace(int face) { this.face = face; } //set suit public void setSuit(int suit) { this.suit = suit; } }//Testdriverclass Testdriver{ //main method public static void main (String[] args) { //creates and print five random cards System.out.println (new Card()); System.out.println (new Card()); System.out.println (new Card()); System.out.println (new Card()); System.out.println (new Card()); //creates five specific cards Card card1 = new Card(1,1); Card card2 = new Card(2,9); Card card3 = new Card(3,5); Card card4 = new Card(4,13); Card card5 = new Card(5,15); //print five specific cards System.out.println (card1); System.out.println (card2); System.out.println (card3); System.out.println (card4); System.out.println (card5); }} Computer Science Engineering & Technology Java Programming CMPT 100 Share QuestionEmailCopy link Comments (0)


