Declare the class Bike and define the following fields of this class (with the access modifier private): wheels (no of wheels) , brand , year, price,  color and quantity. Create a constructor of this class consisting of the previously mentioned fields. Create methods to return each of the fields and methods to set values for each of the fields. Additionally, create the sell() method (simulating bike sales) which will change the value of the quantity field when called. The last method to create is the toString() method that returns an object of type String and prints the names of all fields of a given object and values. Create another class with the main() method in it. Create an object of the Bike class by using the constructor. Call the toString() method and print the details. Call the sell() method. Print all fields (using the previously declared getter methods of the object field).

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Declare the class Bike and define the following fields of this class (with the access modifier private): wheels (no of wheels) , brand , year, price,  color and quantity.

Create a constructor of this class consisting of the previously mentioned fields. Create methods to return each of the fields and methods to set values for each of the fields. Additionally, create the sell() method (simulating bike sales) which will change the value of the quantity field when called.

The last method to create is the toString() method that returns an object of type String and prints the names of all fields of a given object and values.

Create another class with the main() method in it. Create an object of the Bike class by using the constructor. Call the toString() method and print the details.

Call the sell() method. Print all fields (using the previously declared getter methods of the object field).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage