0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

課題((public) Carクラスの作成)

Last updated at Posted at 2020-01-31

class Car {

int num;
double gas;

void show() {
	System.out.println("車のナンバーは" + num + "です。");
	System.out.println("ガソリンの量は" + gas + "です。");
}

void setNumGas(int n, double g) {
	num = n;
	gas = g;
	System.out.println("車のナンバーを" + num + "にガソリン量を"
				+ gas + "にしました。");
}

void charge(double fuel){
	//fuel = gas;
	fuel += gas;
	System.out.println("ガソリン量を" + fuel + "にしました。");
}

}

class publicCarClass {
public static void main(String[] args) {

	Car car1 = new Car();
	
	int number = 1234;
	double gasoline = 20.5;
	
	car1.setNumGas(number, gasoline);
	
	double kyuyu = 10.0;
	car1.charge(kyuyu);
}

}

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?