Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a review exercise, so the primary goal of the exercise is to get your mind working and in the correct space. In

This is a review exercise, so the primary goal of the exercise is to get your mind working and in the correct space. In this- ( operatorname{get} mathrm{O}(mathrm{l} ) - getName() - getCost() - This method should find and return the integer coInside your main class do the following - Create an array that can hold 10 cards. - Fill the array with 5 cards with names an  
 

This is a review exercise, so the primary goal of the exercise is to get your mind working and in the correct space. In this activity you will create an object that models a card from a hypothetical card game. This Card class will model a card with three attributes labeled R, P and S, where each of these values are within a range of 1 R, P, S value 100. You will then create an array of these values and test them out. Using Java, create the following classes and primary program that uses the classes that you developed. INSTRUCTIONS Create the following classes. CARD CLASS Create a Card class. Each card will have three integer values (R,P, and S) within the boundaries set above, and a title which is a string. You will need to create the following methods. . A default constructor that picks random numbers [1,100] for R, P, S and gives the card a random name of "CARD #?????", where the question marks a number between 10000 and 99999. For example "Card #45624" or "Card #12352". A constructor that allows the user to start with a given name. In this case, the constructor should give the Card random R,P,S values, but use the given name. A parameter constructor that allows the programmer to input all 4 pieces of information. (R, P, S, name) . Check the parameters for valid input based on the constraints. If any of the input values is invalid, that particular value should be set to 1. i.e. don't let the RPS values be outside the values getR() getP() . Revised: Winter 2023 . gets() getName() getCost () o This method should find and return the integer "cost" of the card. o The cost of the card will be a value between 1 and 200. The formula for finding the cost of a card is given below: . O X = 100 R-P IR-S + R+P+s R+P+s Note the absolute value symbols in there. o Y = [X] Cost = 200 - Y [x] is the floor function Is-Pl R+P+s + Example 1 toString() o This should print out the name of the card, and the RPS values, and the cost of the card in the format below: o Example 2 Card #23987 [2,5,7:129] Version 2.0 Purple Knight [55,66,1:93] pickValue() o This method should return a single character: an 'R' or 'S' or 'P'. The character returned should be chosen at random based upon the values inside the card. What you should do is find the total value of R+P+S and then give each value an appropriate random value based upon the total and pick at random. O EXAMPLE: MAIN CLASS Inside your main class do the following Create an array that can hold 10 cards. . . o Fill the array with 5 cards with names and values of your choice. Not the user's choice, your choice as the programmer. o Fill the array with 3 named cards but with random values. Finish filling the array with two default cards. Print off all the cards in the array. Print #--- Then do the following loop. Revised: Winter 2023 . o Pick two cards at random. o o o Note, they might be the same card. Pick a Value ['R', 'P', 'S'] for card 1. Pick a Value ['R', 'P', 'S'] for card 2 Determine who wins or if there is a tie: Remember R beat S S beats P . P beats R And it is a tie if they are the same. Print out the result like the following Round 4 Pawn Two beats Blue King S vs P OR Round 5 Card # 18567 ties White Rook S vs S. Repeat the loop above until there are at least 10 ties. Print #- Print out the total number of rounds. Version 2.0

Step by Step Solution

3.41 Rating (157 Votes )

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

Macroeconomics

Authors: Glenn Hubbard, Anthony Patrick O'Brien, Matthew P Rafferty

1st Edition

978-0132109994, 0132109999

More Books

Students also viewed these Accounting questions

Question

8.8 Evaluate methods of treating substance use disorders.

Answered: 1 week ago