Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TEACHING-MATERIALS/Week_03_XML_and_Gradle/MyXml/app/src/main/java/com/example/jianhuayang/myxml/Vehicle.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
79 lines (63 sloc)
1.49 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.jianhuayang.myxml; | |
/** | |
* Created by jianhuayang on 09/10/2017. | |
*/ | |
public class Vehicle { | |
public static int counter = 0; | |
private String make; | |
private int year; | |
private String message; | |
private int price; | |
private double engine; | |
public int getPrice() { | |
return price; | |
} | |
public double getEngine() { | |
return engine; | |
} | |
// the default constructor | |
public Vehicle() { | |
this.make = "Volvo"; | |
this.year = 2012; | |
this.message = "This is the default message."; | |
} | |
public String getMake() { | |
return make; | |
} | |
/* | |
* This constructor takes four parameters. | |
*/ | |
public Vehicle(String make, int year, int price, double engine) { | |
this.make = make; | |
this.year = year; | |
this.price = price; | |
this.engine = engine; | |
this.message = "Your car is a " + make + " built in " + year + "."; | |
count(); | |
} | |
/** | |
* @param make the make of your car | |
*/ | |
public Vehicle(String make) { | |
this(); | |
this.make = make; | |
message = "You didn't type in year value."; | |
count(); | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
@Override | |
public String toString() { | |
return message; | |
} | |
private void count() { | |
this.counter++; | |
} | |
interface Controllable { | |
void control(); | |
} | |
} | |