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)...
-
Explain: Without a market for pollution rights, dumping pollutants into the air or water is costless; in the presence of the right to buy and sell pollution rights, dumping pollutants creates an...
-
This step requires you to complete some exceptions testing for the Employee p-card expenditures for the year ended 12/31/2020. Required: a. How many unique employees exceeded their annual authorized...
-
Your design team is working on an air-core toroid that is to have the greatest feasible magnetic field per ampere of current but in which the greatest magnetic field magnitude must be exactly four...
-
DIVIDEND ALLOCATIONS Situation 1 Espino Company has the following stock outstanding: Common Stock Preferred Stock 100,000 shares..9,000 shares $0.50 par value.$20 par, $2 dividend The amount...
-
(a) The Treasury desk of a global bank incorporated in UK wants to invest GBP 200 million on 1st January, 2019 for a period of 6 months and has the following options: (1) The Equity Trading desk in...
-
1. Case Exhibit 2 presents monthly data of units produced and sold, and actual costs incurred, for 24 months. B Create a scatterplot of costs and units. b. From your scatterplot, estimate the...
-
How does Adlerian counsellors use clients' early recollections as part of the lifestyle assessment? How can clients in counselling benefit from the application of Jung's theory of psychological types?
-
Construct state space model for the mechanical system shown in Fig. P7.7. N oooooo 000000 4 Control force U 5 3.5 Y Ty 2.5
-
Consider the following properties attributed to state model of a system. 1. State model is unique. 2. State model can be derived from the system transfer function. 3. State model can be derived for...
-
Obtain controllability and observability matrices and investigate whether or not the following system is completely controllable and/or completely observable. \[ \begin{aligned} &...
-
A unity feedback system has the loop transmittance \[ \mathrm{G}(s)=\frac{1000 \mathrm{~K}}{s(s+40)(s+100)} \] Design a lead compensator so as to achieve the following specifications: (i) Peak...
-
Develop state space model for each of the electrical networks shown below. Investigate if each one of them is completely controllable and/or completely observable. Substantiate the result with...
-
a. Obtain the linear trend equation for the following data on new checking accounts at Fair Savings Bank and use it to predict expected new checking accounts for periods 16 through 19. (Round your...
-
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,...
-
A vendor at the local art fair ties her tent to the concrete-filled coffee can shown in Figure P5.34. A stiff breeze comes up and the string becomes taut. What is the maximum value that the string...
-
A dump truck, whose bed is made of steel, holds an old steel watering trough. The bed of the truck is slowly raised until the trough begins to slide. What is the acceleration of the trough as it...
-
The acceleration of the spacecraft in which the Apollo astronauts took off from the moon was 3.4 m/s 2 . On the moon, g = 1.6 m/s 2 .What was the apparent weight of a 75 kg astronaut during takeoff?
Study smarter with the SolutionInn App