init
This commit is contained in:
24
Question22-FunctionAndLambda/src/Car.java
Normal file
24
Question22-FunctionAndLambda/src/Car.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 作成 Rhizome
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
import java.util.Random;
|
||||
|
||||
public class Car {
|
||||
String color;
|
||||
int gasoline;
|
||||
Driver driverInfo;
|
||||
|
||||
int run() {
|
||||
this.gasoline--;
|
||||
|
||||
if (gasoline < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
int distance = random.nextInt(15) + 1;
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user