Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE SOLVE IN JAVA [A] Create a class called Cycle which has two instance integer variables as properties, numberOfWheels and weight. Create a constructor with

PLEASE SOLVE IN JAVA

[A] Create a class called Cycle which has two instance integer variables as properties, numberOfWheels and weight. Create a constructor with two parameters, using the same variable names in the parameter list. Assign each variable to numberOfWheels and weight respectively. Write a separate application to test the class and display its properties. Note: Do not change the names of the instance variables or the variables listed in the constructors parameter list.

[B] Edit your class Cycle by adding a default constructor which will assign the default values of 100 to represent the numberOfWheels, and 1000 to represent the weight, by invoking a call to the other constructor. Modify your application created in [A] to test the class.

Directions

[A] Create a class called Cycle

  • Declare integer instance variables numberOfWheels and weight as private.
  • Include a toString() method in the Cycle class. No set or get methods are included.
  • Create a constructor with two parameters, using the same variable names numberOfWheels and weight in the parameter list. Complete the constructor as necessary.
  • Create a separate application to test the class.
    • Create an object of the Cycle class.
    • Display the properties of the object.

[B] Add a default constructor

  • Edit the default constructor such that the default constructor will invoke the existing constructor with the default values of 100 to represent the numberOfWheels, and 1000 to represent the weight. Invoke the constructor using the this reference.
    • Create the second constructor which will receive the two arguments.
  • Create a separate application to test the class.
    • Create an object of the Cycle class.
    • Display the properties of the object.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions