7. Refer to the following class diagram in Figure 9.6: [Rujuk kepada kelas rajah yang berikut:]...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
7. Refer to the following class diagram in Figure 9.6: [Rujuk kepada kelas rajah yang berikut:] i. ii. Implement the classes. Assuming that Food is an abstract class and Convertible is an interface. [Laksanakan kelas-kelas tersebut. Dianggap kelas Food ialah kelas abstrak dan Convertible ialah sebuah interface.] The Convertible interface converts the following: a. weight in pound to gram, i.e. poundToGram = 435.59 b. US currency to Malaysian Ringgit, i.e. UStoMalaysian = 3.45 [Interface Convertible menukarkan yang berikut: a. berat daripada pound ke gram, iaitu, poundToGram = 435.59 b. matawang US ke Ringgit Malaysia, iaitu UStoMalaysia = 3.45] iii. The Food class contains abstract method (named display Info()) whose purpose is to display a brief information about a food, such as: [Kelas Food mengandungi metod abstrak (bernama display Info()) yang bertujuan untuk memaparkan maklumat ringkas sesuatu makanan seperti:] iv. Food description: Celery Weight in pound: 1 pound Weight in gram : 453.6 grams Price: US3.00 Price converted to Malaysian M RM10.35 Food description: Rambutan in syrup Canned Food Type: fruit Expired date: 12/12/12 267 Scanned with CamScanner LAB 9: POLYMORPHISM -DYNAMIC BINDING & ABSTRACT & INTERFACE Price: US5.00 Price converted to Malaysian = RM17.25 Write the application program to test the classes named FoodApp. The program must apply a polymorphism concept and the sample output of the application is as shown in part (iii) above. [Tulis aturcara aplikasi bernama FoodApp untuk menguji kelas-kelas di atas. Aturcara tersebut perlu menggunakan konsep polymorphism dan contoh output untuk aplikasi tersebut seperti yang ditunjukkan di dalam bahagian (iii) di atas.] weight int Vegetable * Vegetable (String, double, int) calcWeight InGram(): double <<Interface>> Convertible poundToGram- 435.59 UStoMalaysian 3.45 <<abstract >> Food description : String price: double + Food (); + Food (String, double) get Description (): String + get Price (): double + calcPriceInRinggit (): double abstract displayInfo(): String FoodApp Canned Food type String expiredDate: String + Canned Food (String, double, String, String) static main(String[1) Figure 9.6 7. Refer to the following class diagram in Figure 9.6: [Rujuk kepada kelas rajah yang berikut:] i. ii. Implement the classes. Assuming that Food is an abstract class and Convertible is an interface. [Laksanakan kelas-kelas tersebut. Dianggap kelas Food ialah kelas abstrak dan Convertible ialah sebuah interface.] The Convertible interface converts the following: a. weight in pound to gram, i.e. poundToGram = 435.59 b. US currency to Malaysian Ringgit, i.e. UStoMalaysian = 3.45 [Interface Convertible menukarkan yang berikut: a. berat daripada pound ke gram, iaitu, poundToGram = 435.59 b. matawang US ke Ringgit Malaysia, iaitu UStoMalaysia = 3.45] iii. The Food class contains abstract method (named display Info()) whose purpose is to display a brief information about a food, such as: [Kelas Food mengandungi metod abstrak (bernama display Info()) yang bertujuan untuk memaparkan maklumat ringkas sesuatu makanan seperti:] iv. Food description: Celery Weight in pound: 1 pound Weight in gram : 453.6 grams Price: US3.00 Price converted to Malaysian M RM10.35 Food description: Rambutan in syrup Canned Food Type: fruit Expired date: 12/12/12 267 Scanned with CamScanner LAB 9: POLYMORPHISM -DYNAMIC BINDING & ABSTRACT & INTERFACE Price: US5.00 Price converted to Malaysian = RM17.25 Write the application program to test the classes named FoodApp. The program must apply a polymorphism concept and the sample output of the application is as shown in part (iii) above. [Tulis aturcara aplikasi bernama FoodApp untuk menguji kelas-kelas di atas. Aturcara tersebut perlu menggunakan konsep polymorphism dan contoh output untuk aplikasi tersebut seperti yang ditunjukkan di dalam bahagian (iii) di atas.] weight int Vegetable * Vegetable (String, double, int) calcWeight InGram(): double <<Interface>> Convertible poundToGram- 435.59 UStoMalaysian 3.45 <<abstract >> Food description : String price: double + Food (); + Food (String, double) get Description (): String + get Price (): double + calcPriceInRinggit (): double abstract displayInfo(): String FoodApp Canned Food type String expiredDate: String + Canned Food (String, double, String, String) static main(String[1) Figure 9.6
Expert Answer:
Answer rating: 100% (QA)
Code Convertiblejava create an interface named Convertible public interface Convertible public double poundToGram 43559 public double UStoMalaysian 345 Foodjava create a class named Food that implemen... View the full answer
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
Three point charges q, 2q and 8q are to be placed on a 9 cm long straight line. Find the positions where the charges should be placed such that the potential energy of this system is minimum. In this...
-
Sunspot Beverages, Limited, of Fiji uses the weighted-average method in its process costing system. It makes blended tropical fruit drinks in two stages. Fruit juices are extracted from fresh fruits...
-
After deducting capital allowances for the year to 31 December 2019, the tax written down values of a company's plant and machinery were as follows: Calculate the capital allowances available for the...
-
You are the CFO of a Canadian firm that is considering building a $10 million factory in Russia to produce milk. The investment is expected to produce net cash flows of $3 million every year for the...
-
Consider the situation of a researcher approached by Captain Johns in the Research Snapshot of this chapter. a. Provide a critique of the procedures used to support the claim that Sea Snappers...
-
A military jet traveling at \(1500 \mathrm{~m} / \mathrm{s}\) has engine trouble and the pilot must bail out. Her ejection seat shoots her forward at \(300 \mathrm{~m} / \mathrm{s}\) relative to the...
-
The Cheadle Company purchased a fleet of 20 delivery trucks for $8,000 each on January 2, 2007. It decided to use composite depreciation on a straight-line basis, and calculated the depreciation from...
-
Design test cases to achieve loop coverage on the function "computeTax" (list the loops covered by each test case). If it is not feasible, explain the reason. Try your best to use the minimum number...
-
Ken (birthdate July 1, 1987) and Amy (birthdate July 4, 1989) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of...
-
8In a flower called Japanese Fouroclocks when red flowers are crossed with white ones they always produce pink colored flowers an example of incomplete dominance Two pink colored flowers when crossed...
-
Choose from any of the four short stories excerpted, and discuss why and how its themes should be considered relevant today. The most recent of these selections ("Cathedral") was published in 1981....
-
Beefsteak is a fast-casual restaurant concept from acclaimed Chef Jos Andrs that focuses on the "unsung power of vegetables" (Beefsteak Company Background Packet, n.d., page 7). Jos Andrs is a...
-
The watershed shown in the figure provided is approximately 150,000 acres in size. The locations of six rain gauges located in the vicinity of the watershed are shown in the figure. The long-term...
-
Explain HOW monetary policy works and Select an issue and brainstorm some questions that you would want to investigate which could be a focus of a blog. please give me a long and proper formed answer...
-
Any asset whose economic and social aspects are fixed in a formal property system (enforced private property rights) Question 2 options: provides for the smaller increases in productivity. is...
-
Find the rank and nullity of the [2 0 4 -7 2 4 6 A 1 -5 2 7 -9 2 4 -41 Verify that values obtained verify the dimension theorem.
-
(a) How far away can a human eye distinguish two ear headlights 2.0 m apart? Consider only diffraction effects and assume an eye pupil diameter of 5.0 mm and a wavelength of 550 nm. (b) What is the...
-
First, write down a list of your daily activities that you typically do on a weekday. For instance, you might get out of bed, take a shower, get dressed, eat breakfast, dry your hair, brush your...
-
Section 3.3 presents basic operation and possible implementations of multipliers. A basic unit of such implementations is a shift - and-add unit. Show a Verilog implementation for this unit. Show how...
-
Th e table below shows 32-bit values of an array stored in memory. Address .............Data 24 ..........................2 38 ..........................4 32 ..........................3 36...
-
What is so special about services marketing that it needs a special approach?
-
How is branding used in services marketing? What is the distinction between a corporate brand such as Marriott and the names of its various inn and hotel chains?
-
The 4 Ps are all a marketing manager needs to create a marketing strategy for a service business. Prepare a response that argues against this, and support it with examples.
Study smarter with the SolutionInn App