This is a review exercise, so the primary goal of the exercise is to get your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Macroeconomics
ISBN: 9780132109994
1st Edition
Authors: Glenn Hubbard, Anthony Patrick O'Brien, Matthew P Rafferty
Posted Date:
Students also viewed these accounting questions
-
In this C++ program, you will create an object and display it. Create a class nerfGun that includes data members model (string), range(int), capacity (int), and number of darts (int). Your class...
-
Which of the following should be the primary goal of a CEO of a publicly-traded company? A) Maximize the profit margin B) Minimize the risk of bankruptcy C) Maximize the market share D) Maximize the...
-
If the primary goal of an executive is to increase the value of the organization, how does ethics and governance play into their decision-making process?
-
Uniform rod AB of length l and mass m lies in a vertical plane and is acted upon by a couple M. The ends of the rod are connected to small rollers which rest against frictionless surfaces. (a)...
-
The bank portion of the bank reconciliation for Backhaus Company at November 30, 2010, was as follows. The adjusted cash balance per bank agreed with the cash balance per books at November 30. The...
-
What advantages and disadvantages would Carrefour likely have compared with domestic retailers where it operates?
-
Even though a businesss trial balance balanced, the following errors have been detected. You are required to prepare the correcting journal entries. a. A payment of \($550\) for rent was incorrectly...
-
The Metropolitan Arts Council (MAC) wants to advertise its upcoming season of plays, concerts, and ballets. A television commercial that costs $25,000 will supposedly reach 53,000 potential arts...
-
and the number of laps around the block (y variable) players could run immediately afterward. The the number of slices of pizza consumed (x variable) by players on a football LSRL for this data is: y...
-
a. In Chapter 9, you created a Tic Tac Toe game in which you used a 2D array of characters to hold Xs and Os for a player and the computer. Now create a JPanel that uses an array of nine JButtons to...
-
Which vessel is known as the window maker because blockage of the vessel causes many fatal heart attacks?
-
Troy Engines, Limited, manufactures a variety of engines for use in heavy equipment. The company has always produced all of the necessary parts for its engines, including all of the carburetors. An...
-
Find 10 partial sums of the series. (Round your answers to five decimal places.) 00 6 n = 1 6 n+1 n Sn 1 2 3 4 5 6 7 8 9 10
-
Suppose that the following information was available for Sheridan Company at December 31, 2025: beginning inventory $102000; ending inventory $110000; cost of goods sold $820440; and sales $1176000....
-
I am doing a study on breathalyzers between male and females. A man weighing 210 had eight beers [12 ounce 5%] starting at 9:00 p.m. What time must he stop to pass the breathalyzer test. The woman...
-
How do varying levels of organizational commitment influence employee turnover rates, and what strategies can be implemented to reduce turnover by enhancing commitment ?
-
3 Accounting Volume 1,... x About Support EX 6-6 Perpetual inventory using FIFO and Beginning inventory, purchases, and sales data for watches are as follows: weighted average Inventory May 1 850...
-
Tiger, Inc. signed a lease for equipment on July 1, 2007.The lease is for 10 years (the useful life of the asset).The first of 10 equal annual payments of $500,000 was made on July 1, 2007.The...
-
Calculate the following growth rates for Ireland. a. Based on problem 3.4, write Irelands growth accounting equation for labor productivity growth. b. Find the relative contribution of growth in the...
-
Hyperinflation occurred in the South during the U.S. Civil War (18611865). Unable to tax effectively in a largely agricultural economy, the Confederate government was forced to print money,...
-
During the late 1990s, U.S. asset markets were growing rapidly, making the United States attractive to foreign savers. At the same time, strong economic growth made firms optimistic about the future,...
-
Lomax Company reported the following costs on its financial statements (in thousands): REQUIRED: Using the reserve disclosure for Lomax Company in problem 13 and the data presented in this problem,...
-
Lomax Companys Statement No. 69 disclosures included the following information: REQUIRED: Using the information for Lomax Company in problems 13, 14, and 15 and in this problem: a. Compute the value...
-
Lomax Company reported the following expenses in its financial statements (in thousands): REQUIRED: Using the reserve disclosure for Lomax Company given in problem 13 and the data presented in this...
Study smarter with the SolutionInn App