Coding Basic dr.Java codes, programming homework help

Description

Having Trouble Meeting Your Deadline?

Get your assignment on Coding Basic dr.Java codes, programming homework help  completed on time. avoid delay and – ORDER NOW

1. Write a class called Rectangle that represents a rectangular two-dimensional region. Your Rectangle objects should have the following methods:

Public Rectangle (int x, int y, int width, int height)

Construct a new Rectangle whose top-left corner is specified by the given coordinates and with the given width and height.

public int getHeight()

Returns the Rectangle’s height.

public int getWidth()

Returns the Rectangle’s width.

public int getX()

Returns the Rectangle’s x-coordinate.

public int getY()

Returns this Rectangle’s y-coordinate.

Also write a small client program to test the methods of the class (i.e. use the client program to create a rectangle object from this class, and call the methods getHeight(),getWidth() …etc.

2. 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 field is an int that holds the car’s speed

In addition, the class should have the following constructor and other methods:

  • Car: accepts the car’s year model and make as arguments. These values should be assigned to the object’s yearModel and make. Sets speed to 0.
  • getYearModel: returns the year
  • getMake: returns the make
  • getSpeed: returns the speed
  • accelerate: The accelerate method should add 5 to the speed field each time it is called.
  • brake: The brake method should subtract 5 from the speed field each time it is called.

Demonstrate the class in a program that creates a Car object, and then calls the accelerate method five times. 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.

Explanation & Answer

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Order Now and we will direct you to our Order Page at Litessays. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Similar Posts