Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

The first part is the question the homework assignment asks for and the second part is the piece to complete the last part, question the

The first part is the question the homework assignment asks for and the second part is the piece to complete the last part, question the first part asks for.

image text in transcribed

image text in transcribed

image text in transcribed

Instructions: In the class textbook (Introduction to Programming with Java: A Problem Solving Approach 3rd ed, John Dean & Raymond Dean) go to chapter 13 and do exercise 14, on page 634. The exercise asks you to create a class structure for a card games. NOTE: this problem references exercise 13 from the same chapter; it describes the UML structure of the problem. You do not have to turn in UML - just code to implement the solution asked for in exercise 14. Write and submit the Java code that correctly represents a solution to the problem. class definition will contain declarations for variables. 12. (after $13.91 Identification of type of association: Given the following list of word pairs, for each word pair, identify the association between the two words. That is, identify whether the two words are related by composition or inheritance. To get you started, we've provided the answers to the dirst two word pairs. Vehicle and spare are related by composition berasse a vehicle hesa" pastire or tube). Vehicle and bicycle are related by inheritance because a ticycle 'is a" vebicie. inheritance or composition? bicycle inheritance composition residence yine unding vegetation person animal language army method raccook French soldier parameter 13. [after $13.10] Shuffling: Suppose you are developing a card game program like that suggested earlier in the chapter, but you want to use an ArrayList instead of an array. The following UML class diagram shows your plan: GroupOfCards -cards : ArrayList 1 Card +getCards(): ArrayList +addCard(card : Card) : void +removeCard(card : Card) : Card +display(heading : String): void -num : int -suit: int +Card(num : int, suit: int) +display() : void Deck Driver Deck +TOTAL CARDS : int=52 +main(args : String[]) : void +Deck() +shuffle(): void Assume you have implemented the Card class and the GroupOfCards class. (The next exercise will ask you to do this.) Assume that the addCard method adds its passed-in card to the end of the ArrayList. Assume that the removeCard method deletes the passed-in card from the ArrayList (reducing the ArrayList's size by one) and returns a reference to the removed card. Provide Java code for the Deck and DeckDriver classes. In your Deck class, you must implement a shuffle method that relies on the 634 Chapter 13 Aggregation, Composition, and inheritance addCard and removeCard methods. You are not allowed to use the Collection class's shuffle method. When you execute the driver, you should get output like that in the following sample session, with randomness altering the output after shuffling: Sample session: Unshuffled Deck 2 of clubs 3 of clubs Deck After Shuffling 14 of spades 3 of hearts Hint: To shuffle the deck, in the Deck class's shuffle method, use a for loop that starts with unshuffled = getCards().size and steps down to 1. In each iteration, use Math.random to pick an index in the unshuffled range, remove the card at that index, and then add it back to the ArrayList. 14. (after $13.10] This is a continuation of the card game program described in the prior exercise. Implement the Card and GroupOfCards classes. 15. (after $13.2] (Case Study) GridWorld's first Project file contains the BugRunner driver: public class BugRunner [ public static void main(String[] args) C ActorWorld worid - new ActorWorld(); world.add(new Bug(): world.add(new Rock(): world.show(): 1 // end main ) // end class BugRunner BugRunner starts by creating an instance of ActorWorld named world. ActorWorld's constructor immediately creates a 10 x 10 BoundedGrid. Next, BugRunner asks the ActorWorld object to add a new Bug at a random location, and it then adds a new Rock at a different random location ActorWorld's add mathod tolle ang nam

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_2

Step: 3

blur-text-image_3

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students explore these related Databases questions