Write the code for the following UML diagram. Input(): Ask user to provide values for color and fuel. Default values for speed is “0” and state is “stopped” addFuel(): Ask user to provide value for fuel to add. Add that value in fuel (attribute) and return value of total fuel. moving(): Ask user to provide the speed of vehicle and fuel Set the value of speed and reduce the fuel (attribute) according to fuel consumption. And also set the state to “Moving”. stop(): This method will display that “Vehicle is stopped” and sets the value of speed to “0” and state to “Stopped” display(): This method will display the attributes value to output like: “Vehicle is stopped. It has red color. It’s speed is 0.0 and fuel is 2.5 Liter”
Write the code for the following UML diagram. Input(): Ask user to provide values for color and fuel. Default values for speed is “0” and state is “stopped” addFuel(): Ask user to provide value for fuel to add. Add that value in fuel (attribute) and return value of total fuel. moving(): Ask user to provide the speed of vehicle and fuel Set the value of speed and reduce the fuel (attribute) according to fuel consumption. And also set the state to “Moving”. stop(): This method will display that “Vehicle is stopped” and sets the value of speed to “0” and state to “Stopped” display(): This method will display the attributes value to output like: “Vehicle is stopped. It has red color. It’s speed is 0.0 and fuel is 2.5 Liter”
Chapter2: Using Data
Section: Chapter Questions
Problem 1GZ
Related questions
Question
Write the code for the following UML diagram.
- Input(): Ask user to provide values for color and fuel. Default values for speed is “0” and state is “stopped”
- addFuel(): Ask user to provide value for fuel to add. Add that value in fuel (attribute) and return value of total fuel.
- moving(): Ask user to provide the speed of vehicle and fuel Set the value of speed and reduce the fuel (attribute) according to fuel consumption. And also set the state to “Moving”.
- stop(): This method will display that “Vehicle is stopped” and sets the value of speed to “0” and state to “Stopped”
- display(): This method will display the attributes value to output like:
“Vehicle is stopped. It has red color. It’s speed is 0.0 and fuel is 2.5 Liter”
![Vehicle
-color:String
-speed:double
-fuel:double
+state: String
+input():void
+addFuel(): double
+moving():void
+stop():void
+display():void](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff9c86bdf-bd78-4306-a554-e0b382941c38%2F7e38cbc6-d3eb-4ec0-92d7-a5eea92094f7%2F8koaf6n_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Vehicle
-color:String
-speed:double
-fuel:double
+state: String
+input():void
+addFuel(): double
+moving():void
+stop():void
+display():void
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT