Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

please write comments in java eclipse and send a screenshot of the output.

[画像:**Part 1: Create a new package HW5 and create a Parent Class called "Fruit" strictly based on the UML.** (Do not include anything extra, do not miss any data fields or methods. `#` denotes protected visibility modifier. *Underline* denotes static variable and static method.) Add the line "numberOfFruits++;" at the end of both constructors (as the last statement). *Add comments to your program* (comment for the data fields, constructors, getters, setters and toString() methods). We will use `enum Color` to denote a fruit’s color. Add the code for `enum Color` on top of the class. ```java enum Color { YELLOW, ORANGE, RED, PURPLE; } ``` --- ### Diagram Explanation: The diagram illustrates the structure of the `Fruit` class. Below is a detailed explanation of the UML diagram: - **Attributes:** - `- color: Color` : A private attribute to store the color of the fruit. - `- calories: int` : A private attribute to store the number of calories. - `- pricePerPound: double` : A private attribute to store the price per pound. - `# numberOfFruits: int` : A protected static attribute to keep track of the number of fruits. - **Constructors:** - `+ Fruit()`: A public default constructor. - `+ Fruit(color: Color, calories: int, pricePerPound: double)`: A public constructor that initializes a fruit with specific values for color, calories, and price per pound. - **Methods:** - `+ getColor(): Color`: A public method to return the color of the fruit. - `+ setColor(color: Color): void`: A public method to set the color of the fruit. - `+ getCalories(): int`: A public method to return the calories of the fruit. - `+ setCalories(calories: int): void`: A public method to set the calories of the fruit. - `+ getPricePerPound(): double`: A public method to return the price per pound of the fruit. - `+ setPricePerPound(pricePerPound: double): void`: A public method to set the price per pound of the fruit. - `+ getNumberOfFruits(): int`: A public static method to return]
expand button
Transcribed Image Text:**Part 1: Create a new package HW5 and create a Parent Class called "Fruit" strictly based on the UML.** (Do not include anything extra, do not miss any data fields or methods. `#` denotes protected visibility modifier. *Underline* denotes static variable and static method.) Add the line "numberOfFruits++;" at the end of both constructors (as the last statement). *Add comments to your program* (comment for the data fields, constructors, getters, setters and toString() methods). We will use `enum Color` to denote a fruit’s color. Add the code for `enum Color` on top of the class. ```java enum Color { YELLOW, ORANGE, RED, PURPLE; } ``` --- ### Diagram Explanation: The diagram illustrates the structure of the `Fruit` class. Below is a detailed explanation of the UML diagram: - **Attributes:** - `- color: Color` : A private attribute to store the color of the fruit. - `- calories: int` : A private attribute to store the number of calories. - `- pricePerPound: double` : A private attribute to store the price per pound. - `# numberOfFruits: int` : A protected static attribute to keep track of the number of fruits. - **Constructors:** - `+ Fruit()`: A public default constructor. - `+ Fruit(color: Color, calories: int, pricePerPound: double)`: A public constructor that initializes a fruit with specific values for color, calories, and price per pound. - **Methods:** - `+ getColor(): Color`: A public method to return the color of the fruit. - `+ setColor(color: Color): void`: A public method to set the color of the fruit. - `+ getCalories(): int`: A public method to return the calories of the fruit. - `+ setCalories(calories: int): void`: A public method to set the calories of the fruit. - `+ getPricePerPound(): double`: A public method to return the price per pound of the fruit. - `+ setPricePerPound(pricePerPound: double): void`: A public method to set the price per pound of the fruit. - `+ getNumberOfFruits(): int`: A public static method to return
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY