Question
You are developing a new game in which different kinds of disks are played in pairs on a game board. Two disks can be played
You are developing a new game in which different kinds of disks are played in pairs on a game board. Two disks can be played whey they meet the following criteria:
1. Both disks are the same kind (i.e., instances of the same class)
2. Spotted disks have the same number of spots
3. Sided disks have the same number of sides
4. Colored disks are the same color
Write the four canPlay methods (do not write complete classes) indicated in the accompanying UML class diagram without duplicating code (in place of duplicating code, call the canPlay method in a super class). Note that the UML diagram is not complete - it just presents the information relevant to this problem. The typical Java equals method is similar to the canPlay method, but note the argument type in the UML class diagram below. See Horstmann and Cornells recipe for writing the perfect equals method for suggestions (especially for step 1). Disregard the private attribute named "memberName."
Disk +can Play(Disk d) boolean Spotted Disk Fancy Disk -memberName Spots int +can Play(Disk d) boolean Colored Disk Sided Disk -color String sides int +can Play(Disk d) boolean +can Play(Disk d) booleanStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started