Write the class, Potion.java following this UML Diagram and doing the following: Potion -name: String -strength:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write the class, Potion.java following this UML Diagram and doing the following: Potion -name: String -strength: double +Potion() +Potion(name: String, strength: double) +getName(): String +getStrength(): double +setName(name: String) +setStrength(strength: double) +toString(): String +validStrength(strength: double): boolean +equals(p: Potion): boolean 1. Create two instance variables, name (a String) and strength (a double). 2. Write the default constructor. 3. Write the non-default constructor. 4. Write two accessor methods, one for each instance variable. 5. Write two mutator methods, one for each instance variable. 6. Write a method that will return the entire as a single string (the toString method). 7. Write a method that will return true if the strength is between 0 and 10. 8. Write a method that will compare this instance to another Potion (the equals method). 9. Now write an application class that instantiates two instances of Potion. One instance should use the default constructor and the other should use the non-default constructor. Display the values of each object by calling the toString method. Write the class, Potion.java following this UML Diagram and doing the following: Potion -name: String -strength: double +Potion() +Potion(name: String, strength: double) +getName(): String +getStrength(): double +setName(name: String) +setStrength(strength: double) +toString(): String +validStrength(strength: double): boolean +equals(p: Potion): boolean 1. Create two instance variables, name (a String) and strength (a double). 2. Write the default constructor. 3. Write the non-default constructor. 4. Write two accessor methods, one for each instance variable. 5. Write two mutator methods, one for each instance variable. 6. Write a method that will return the entire as a single string (the toString method). 7. Write a method that will return true if the strength is between 0 and 10. 8. Write a method that will compare this instance to another Potion (the equals method). 9. Now write an application class that instantiates two instances of Potion. One instance should use the default constructor and the other should use the non-default constructor. Display the values of each object by calling the toString method.
Expert Answer:
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Posted Date:
Students also viewed these programming questions
-
increascinaccounts payable, $ 3 , 5 2 0 increase in prepaid expenses, and a 5 1 4 , 9 6 0 increase in accumulated depreciation. Prepare the operating activities section of the statement of cash fows...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
We-B-Busy, Inc. uses job costing and a predetermined overheadrate based onmachine hours (MH). The firm estimated that it would use $240,000of MOH and7,500 MH this year. Data for February:Job 1010 2...
-
Express each of the following types of error as an equation: a. Total error b. Random sampling error c. Non response error d. Response error
-
Following several years of tight budgets, administrators at the University of California, Davis, looked for ways to do more with less. Janet Hamilton, vice chancellor of administration, researched...
-
Inventory costing methods The following transactions affecting materials occurred in February: Feb. 1 Balance on hand, 1,200 feet @ $2.76, $3,312.00 (plastic tubing, stores ledger account #906). 5...
-
Table shows data on the returns over five 1-year periods for six mutual funds. A firms portfolio managers will assume that one of these scenarios will accurately reflect the investing climate over...
-
A. Evaluate the functions as indicated. Show the complete solution and express the final answer in its simplest form. 1. Given : f (x) = -x2 - 6x Find : a. f (5x) b. f(3 - h) c. f ( - ;) d I( x+k)-6f...
-
Consolidation Eliminating Entries, First Year Packer Corporation buys 85 percent of the voting stock of Slattery Inc. on January 1, 2023, at an acquisition cost of $10,000,000. The fair value of the...
-
1. Which of the following nominal rates does not apply to a C corporation? a. 10% b. 15% c. 25% d. 35% 2. 2. Which of the following is never included in gross income? a. Loss on stock sale b. Social...
-
Mary carries on business as a sole proprietor that generated $100,000 in net accounting income. Included in this amount are: $7,000 of amortization expense; $4,000 for bad debt expense; $112,000 cost...
-
describe strengths and opportunities about "strategies for competing in international markets" and "ethics, corporate social responsibility, environmental sustainability and strategy" in terms of...
-
XYZ, Inc. reported $20 million in operating current assets, $25 million in net fixed assets, and $6 million in operating current liabilities. What are the inventories and fixed assets for XYZ, Inc.,...
-
Five Star Corporation will pay a dividend of $ 2 . 9 0 per share next year. The company pledges to increase its dividend by 4 percent per year indefinitely. If you require a return of 1 1 percent on...
-
You just graduated from college and will start your first full-time job on Monday. You are a software engineer for a major designer of smartphone apps for the financial services You were able to get...
-
Cosy and Co. produces and sells vases for $100. The company hasthe capacity to produce 50,000 vases each period. At capacity, thecosts assigned to each unit are as follows:Unit level costs 2 answers
-
The words without recourse on an indorsement means the indorser is: a. not liable for any problems associated with the instrument. b. not liable if the instrument is dishonored. c. liable personally...
-
Elements of Internal Control OBJECTIVE 2 Discuss five elements of internal control. Required: Define and discuss these five elements of internal control. Brief Exercise
-
Petty Cash with Change in Fund Balance} Basque Ltd. maintains a petty cash fund with a balance of \(\$ 800\). On December 31, Basque's petty cash account has a balance of \(\$ 60\). Basque...
-
Role of Internal Control Internal controls play a crucial role in a business. Required: CONCEPTUAL CONNECTION Discuss why internal controls are important. What are the potential consequences of an...
Study smarter with the SolutionInn App