started ex Z4
This commit is contained in:
44
src/exercises/ex_z4/Bidder.java
Normal file
44
src/exercises/ex_z4/Bidder.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package exercises.ex_z4;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Bidder implements Runnable {
|
||||
private static int nextId = 0;
|
||||
private final String name;
|
||||
private final int id;
|
||||
private final List<Item> items = new ArrayList<>();
|
||||
private Double lastBid = null;
|
||||
|
||||
public Bidder(String name) {
|
||||
this.name = name;
|
||||
this.id = nextId++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(true){
|
||||
Random rand = new Random();
|
||||
double addon = rand.nextDouble(500);
|
||||
lastBid += addon;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Double getLastBid() {
|
||||
return lastBid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + id + ") " + name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user