Give an example of class or static members, JAVA Programming

Assignment Help:

Give an example of Class or static Members?

Below is a Car class along with such a speedLimit field and getSpeedLimit() method.
public class Car {

private String licensePlate; // e.g. "New York A456 324"
private double speed; // kilometers per hour
private double maxSpeed; // kilometers per hour
private static double speedLimit = 112.0; // kilometers per hour

public Car(String licensePlate, double maxSpeed) {

this.licensePlate = licensePlate;
this.speed = 0.0;
if (maxSpeed >= 0.0) {
this.maxSpeed = maxSpeed;
}
else {
maxSpeed = 0.0;
}

}

// getter (accessor) methods
public static double getSpeedLimit() {
return speedLimit;
}

public boolean isSpeeding() {
return this.speed > speedLimit;
}

public String getLicensePlate() {
return this.licensePlate;
}

public double getMaxSpeed() {
return this.maxSpeed;
}

public double getSpeed() {
return this.speed;
}

// setter method for the license plate property
public void setLicensePlate(String licensePlate) {
this.licensePlate = licensePlate;
}

// accelerate to maximum speed
// put the pedal to the metal
public void floorIt() {
this.speed = this.maxSpeed;
}
public void accelerate(double deltaV) {

this.speed = this.speed + deltaV;
if (this.speed > this.maxSpeed) {
this.speed = this.maxSpeed;
}
if (this.speed < 0.0) {
this.speed = 0.0;
}

}

}


Related Discussions:- Give an example of class or static members

What is file transfer protocol, What is File Transfer Protocol? This pr...

What is File Transfer Protocol? This protocol is used to upload the files on remote computers. This is used to transfer files among computer on TCP/IP network e.g. internet and

Student, what are Objects and Fields in java

what are Objects and Fields in java

Website for swapping and selling books, Website for swapping/selling books ...

Website for swapping/selling books Project Description: Seeking a website where students can sell and buy books. I want them to swap books as well. Payment options are requir

What is an objects lock, What is an object's lock and which objects have lo...

What is an object's lock and which objects have locks? An object's lock is a mechanism that is used by multiple threads to get synchronized access to the object. A thread may i

Develop a purchase order system, Develop a Purchase Order System Project...

Develop a Purchase Order System Project Description: Purchase Order (PO) is one of the first steps in the ordering process of a store. Before, we rely on manual computation t

In javascript what is event handling and inline event, In JavaScript, what ...

In JavaScript, what is event handling? What are the two categories of events? In java script we could capture events on do a few operation on the basis of which particular even

Explain java.util.random package, Explain java.util.Random package? The...

Explain java.util.Random package? The java.util.Random class permits you to create objects which generates pseudo-random numbers along with uniform or gaussian distributions ac

Illustrate java management extensions (jmx)?, JMX framework can enhance the...

JMX framework can enhance the manageability of your application by  1. Monitoring your application for critical events, performance problems, and error condition statistics. E.g

Explain jar archives, Explain JAR Archives ? HTTP 1.0 uses a separate ...

Explain JAR Archives ? HTTP 1.0 uses a separate connection for every request. When you're downloading several small files, the time required to set up and tear down the connec

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd