

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information about quiz 2 for the cmsc 132 course, including the quiz material, instructions, and exercises. Students are required to create uml class diagrams and write code implementation based on the provided classes. The quiz covers association relationships and the use of arraylist, arraylistlist, and enums. No solutions will be provided, but students can discuss their answers with tas and the instructor.
Typology: Quizzes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


CMSC 132 Quiz 2 Worksheet
The second quiz of the course will be on Friday, Jun 16. The following list provides more information about the quiz:
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with TAs and the instructor.
UML Design
public class Roster { private ArrayList
public Roster(int maxSize) { throw new UnsupportedOperationException("Not Implemented"); }
public boolean addStudent(Student s) { throw new UnsupportedOperationException("Not Implemented"); }
public static double[] getStatistics() { throw new UnsupportedOperationException("Not Implemented"); }
public void printInfo() { throw new UnsupportedOperationException("Not Implemented"); }
private void computeGrades() { throw new UnsupportedOperationException("Not Implemented"); } }
a. Implement a class called Deck that represents a deck of 52 cards. Use an ArrayList to represent the deck. For this class define a constructor that initializes the deck of cards with the usual 52 cards present in a deck. The order in which the cards appear in the ArrayList is not relevant (any order will suffice). Notice you are not asked to randomize the cards’ order. b. Define a public method named getCards that returns an ArrayList with the cards in the deck.
c. Add a public method named shuffle that will “shuffle” the cards in the deck using a Random object provided as a parameter.
public enum CardValue { Ace("1"), Two("2"), Three("3"), Four("4"), Five("5"), Six("6"), Seven("7"), Eight("8"), Nine("9"), Ten("10"), Jack("J"), Queen("Q"), King("K");
CardValue(String valueIn) { value = valueIn; } public String getValue() { return value; } public int getIntValue() { switch(this) { case Jack: return 10; case Queen: return 10; case King: return 10; default: return Integer.parseInt(value); } } private String value; }
public enum CardSuit { SPADES("s"), DIAMONDS("d"), HEARTS("h"), CLUBS("c");
CardSuit(String value) { this.value = value; }
public String getValue() { return value; }
private String value; }
public class Card { private CardValue value; private CardSuit suit;
public Card(CardValue value, CardSuit suit) { this.value = value; this.suit = suit; }
public CardValue getValue() { return value; }
public CardSuit getSuit() { return suit; }
public String toString() { String result = ""; result += value + " of " + suit + " ";