68 lines
2.5 KiB
Java
68 lines
2.5 KiB
Java
/*
|
|
* TASK 9
|
|
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/9
|
|
* by femsci
|
|
*/
|
|
|
|
package hai.hello;
|
|
|
|
import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
// meow~
|
|
public class Car {
|
|
int fuel = 35, odometer = 0;
|
|
|
|
public void printFuelLevel() {
|
|
System.out.printf("after filling: %dL >.<\n", this.fuel);
|
|
}
|
|
|
|
public void printStats() {
|
|
System.out.printf("%dkm driven, %dl left\n", this.odometer, this.fuel);
|
|
}
|
|
|
|
public void fill() // >.<
|
|
{
|
|
ThreadLocalRandom r = ThreadLocalRandom.current();
|
|
if (r.nextInt(100) < 10) {
|
|
throw new ExplosionException(this);
|
|
}
|
|
|
|
this.fuel += r.nextInt(15, 36);
|
|
printFuelLevel();
|
|
}
|
|
|
|
// linear funky wunky?
|
|
// public void drive(int distance) throws NotEnoughGasException {
|
|
// }
|
|
|
|
public void drive100km() throws NotEnoughGasException {
|
|
if (this.fuel < 10) {
|
|
throw new NotEnoughGasException(this);
|
|
}
|
|
|
|
this.fuel -= 10;
|
|
this.odometer += 100;
|
|
|
|
printStats();
|
|
}
|
|
|
|
/*
|
|
* ⠀⢸⠂⠀⠀⠀⠘⣧⠀⠀⣟⠛⠲⢤⡀⠀⠀⣰⠏⠀⠀⠀⠀⠀⢹⡀
|
|
* ⠀⡿⠀⠀⠀⠀⠀⠈⢷⡀⢻⡀⠀⠀⠙⢦⣰⠏⠀⠀⠀⠀⠀⠀⢸⠀
|
|
* ⠀⡇⠀⠀⠀⠀⠀⠀⢀⣻⠞⠛⠀⠀⠀⠀⠻⠀⠀⠀⠀⠀⠀⠀⢸⠀
|
|
* ⠀⡇⠀⠀⠀⠀⠀⠀⠛⠓⠒⠓⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀
|
|
* ⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠀
|
|
* ⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⠀⠀⢀⡟⠀
|
|
* ⠀⠘⣇⠀⠘⣿⠋⢹⠛⣿⡇⠀⠀⠀⠀⣿⣿⡇⠀⢳⠉⠀⣠⡾⠁⠀
|
|
* ⣦⣤⣽⣆⢀⡇⠀⢸⡇⣾⡇⠀⠀⠀⠀⣿⣿⡷⠀⢸⡇⠐⠛⠛⣿⠀
|
|
* ⠹⣦⠀⠀⠸⡇⠀⠸⣿⡿⠁⢀⡀⠀⠀⠿⠿⠃⠀⢸⠇⠀⢀⡾⠁⠀
|
|
* ⠀⠈⡿⢠⢶⣡⡄⠀⠀⠀⠀⠉⠁⠀⠀⠀⠀⠀⣴⣧⠆⠀⢻⡄⠀⠀
|
|
* ⠀⢸⠃⠀⠘⠉⠀⠀⠀⠠⣄⡴⠲⠶⠴⠃⠀⠀⠀⠉⡀⠀⠀⢻⡄⠀
|
|
* ⠀⠘⠒⠒⠻⢦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⠞⠛⠒⠛⠋⠁⠀
|
|
* ⠀⠀⠀⠀⠀⠀⠸⣟⠓⠒⠂⠀⠀⠀⠀⠀⠈⢷⡀⠀⠀⠀⠀⠀⠀⠀
|
|
* ⠀⠀⠀⠀⠀⠀⠀⠙⣦⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⠀⠀⠀⠀⠀⠀⠀
|
|
* ⠀⠀⠀⠀⠀⠀⠀⣼⣃⡀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀⠀⠀⠀
|
|
* ⠀⠀⠀⠀⠀⠀⠀⠉⣹⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⠀⠀⠀⠀⠀⠀
|
|
* ⠀⠀⠀⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡆⠀⠀⠀⠀⠀
|
|
*/
|
|
}
|