(Solved) : Graded Activity Creating Classes Write Class Named Car Following Fields Yearmodel Yearmode Q37166542 . . .
Make a UML for this:
Graded Activity -Creating Classes Write a class named Car that has the following fields: yearModel The yearModel field is an int that holds the car’s year model. – make The make field references a String object that holds the make of the car. . speed The speed flield is an int that holds the car’s current speed. The class should have the following constructor and other methods. No-arg constructor that sets yearModel to 2018, make to “Toyota”, speed to o. Parameterized constructor. The constructor should accept the car’s year model and make as arguments These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field Copy constructor that creates a copy of an existing object. Accessors. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and speed fields getYearModel method that returns the value in the yearModel field getMake method that returns the value in the make field getSpeed method that returns the value in the speed field Mutators. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and speed fields setYearModel method that accepts an int argument, which is assigned to the yearModel field setMake method that accepts a String argument, which is assigned to the make field setSpeed method that accepts an int argument, which is assigned to the speed field. If a value less than O is passed, the method should set speed to 0 o o o .accelerate. The accelerate method should add 5 to the speed field each time it is called. It accepts no argument brake. The brake method should subtract 5 from the speed field each time it is called. It also checks updated speed never gets a negative value(Assign the speed to 0, if it goes below 0) It accepts no argument (optional) toString method that returns the values stored in the car object in the following String format: the speed of 2018 modeled Toyota is 0 (optional) equals method to test to see whether or not two car objects are the same Demonstrate the class in a program that creates two Car objects, one with default constructor, one with value entered by the user. And then calls the accelerate method five times on the first created object. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it. Show transcribed image text Graded Activity -Creating Classes Write a class named Car that has the following fields: yearModel The yearModel field is an int that holds the car’s year model. – make The make field references a String object that holds the make of the car. . speed The speed flield is an int that holds the car’s current speed. The class should have the following constructor and other methods. No-arg constructor that sets yearModel to 2018, make to “Toyota”, speed to o. Parameterized constructor. The constructor should accept the car’s year model and make as arguments These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field Copy constructor that creates a copy of an existing object. Accessors. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and speed fields getYearModel method that returns the value in the yearModel field getMake method that returns the value in the make field getSpeed method that returns the value in the speed field Mutators. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and speed fields setYearModel method that accepts an int argument, which is assigned to the yearModel field setMake method that accepts a String argument, which is assigned to the make field setSpeed method that accepts an int argument, which is assigned to the speed field. If a value less than O is passed, the method should set speed to 0 o o o .accelerate. The accelerate method should add 5 to the speed field each time it is called. It accepts no argument brake. The brake method should subtract 5 from the speed field each time it is called. It also checks updated speed never gets a negative value(Assign the speed to 0, if it goes below 0) It accepts no argument (optional) toString method that returns the values stored in the car object in the following String format: the speed of 2018 modeled Toyota is 0 (optional) equals method to test to see whether or not two car objects are the same Demonstrate the class in a program that creates two Car objects, one with default constructor, one with value entered by the user. And then calls the accelerate method five times on the first created object. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it.
Expert Answer
Answer to Graded Activity -Creating Classes Write a class named Car that has the following fields: yearModel The yearModel field i…
OR