Question
Given the following 2 class diagrams. You are to write the method header (include opening and closing brackets and a return statement if one is
Given the following 2 class diagrams. You are to write the method header (include opening and closing brackets and a return statement if one is required) for each method as well as the call statement that would be used from another class to call that method. Object and variable declarations are given below.
1 2 3 4 5 |
| Fruit |
|
| |
|
+ task1():void + task2(int pineapple, double plum):void + task3():double (use plum) + task4(String cherry):int (use apple) + task5(int apple, String strawberry):double (use banana)
|
6 7 8 9 10 |
| Vegetable |
|
- mushroom:String
| |
|
+ getMushroom():String + setMushroom(String mushroom):void + task6():void + task7(int potato, double onion):int (use carrot) + task8(int carrot):int (use potato)
|
Object and Variable declarations:
Fruit fruit = new Fruit();
Vegetable veg = new Vegetable();
int apple = 0;
double banana = 0;
String cherry = null;
double plum = 0;
int pineapple = 0;
String strawberry = null;
Fruit |
1. Method Header
|
1. Call
|
2. Method Header
|
2. Call
|
3. Method Header
|
3. Call
|
4. Method Header
|
4. Call
|
5. Method Header
|
5. Call
|
Vegetable |
6. Method Header
|
6. Call
|
7. Method Header
|
7. Call
|
8. Method Header
|
8. Call
|
9. Method Header
|
9. Call
|
10. Method Header
|
10. Call
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started