Skip to content

Instantly share code, notes, and snippets.

@behitek
Last active November 3, 2016 12:46
Show Gist options
  • Save behitek/aa1033c8252efcfcb387b9852231a17b to your computer and use it in GitHub Desktop.
Save behitek/aa1033c8252efcfcb387b9852231a17b to your computer and use it in GitHub Desktop.
Viết chương trình mô tả đối tượng Car
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package BT1;
/**
*
* @author HieuNguyen
*/
public class Car {
private String carName;
private String carColor;
private int maxSpeed;
public Car() {
}
public Car(String carName, String carColor, int maxSpeed) {
this.carName = carName;
this.carColor = carColor;
this.maxSpeed = maxSpeed;
}
public String getCarName() {
return carName;
}
public void setCarName(String carName) {
this.carName = carName;
}
public String getCarColor() {
return carColor;
}
public void setCarColor(String carColor) {
this.carColor = carColor;
}
public int getMaxSpeed() {
return maxSpeed;
}
public void setMaxSpeed(int maxSpeed) {
this.maxSpeed = maxSpeed;
}
public static void main(String[] args) {
Car car = new Car("Camry", "White", 200);
System.out.println("Car Name: "+car.getCarName()+"\nCar Color: "+car.getCarColor()+"\nCar max speed: "+car.getMaxSpeed());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment