Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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 . - getro - get() - gets(l - getNane() - getcost() This method should find and return the integer "cost" of the card. The cost of the card will be a value between 1 and 200 . a The formula for finding the cost of a card is given below: X=100(R+P+5RP+R+P+5RS+R+P+5SP) - Note the absolute value symbols in there. Y=X] - x is the floor function - Cost =200Y - tostring() This should print out the name of the card, and the RPS values, and the cost of the card in the format below: Example 1 - Card \#23987 [2,5,7:129] Example 2 - Purple Knight [55,66,1:93] - pickvalue() 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. EXAMPLE: - With A card with RPS values of R=5,P=10,5=50 - The total is 50+10+5=65 - So there is a 5/65 chance of picking an R. - So there is a 10/65 chance of picking a P - So there is a 50/65 chance of picking an 5 Inside your main class do the following - Create an array that can hold 10 cards. Fill the array with 5 cards with names and values of your choice. - Not the user's choice, your choice as the programmer. 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. Pick two cards at random. - Note, they might be the same card. Pick a Value ['R', ' P ', ' 'S'] for card 1. Pick a Value ['R', ' P ', 'S' 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 5. - Repeat the loop above until there are at least 10 ties. - Print \# - Print out the total number of rounds. BEFORE SUBMISSION Before submitting your assignment, make sure your program is correctly Java Documented and is listed as your name as the author

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions