Volg de onderstaande video om te zien hoe je onze site als web-app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
package laftest;
import java.security.InvalidParameterException;
/**
*
* @author timmos
*/
public class LAFTest {
public static void main(String[] args) {
try {
int snipe = toMinutes(args[0]);
int close = toMinutes(args[1]);
int bid = -1;
for (int i = 2; i < args.length; i++){
int nextBid = toMinutes(args[i]);
if (nextBid < close){
close = Math.max(close, nextBid + snipe);
bid = nextBid;
} else {
break;
}
}
System.out.println("Winning bid is " + hhmm(bid));
System.out.println("Final closing time is " + hhmm(close));
} catch (Exception ex){
System.out.println("Wrong arguments. Use <snipe> <closingTime> <lastBidBefore> <bidAfter1> ... <bidAfterN>");
}
}
private static int toMinutes(String time){
int timeNr = Integer.parseInt(time);
int hours = timeNr / 100;
int minutes = timeNr % 100;
if (0 <= hours && hours <= 23 && 0 <= minutes && minutes <= 59){
return 60 * hours + minutes;
} else {
throw new InvalidParameterException();
}
}
private static String hhmm(int minutes){
if (minutes < 0)
return "<none>";
String hh = (minutes / 60 < 10 ? "0" : "") + minutes / 60;
String mm = (minutes % 60 < 10 ? "0" : "") + minutes % 60;
return hh + ":" + mm;
}
}
Timmos zei:Java programma voor het berekenen van het geldige bod.
Code:package laftest; import java.security.InvalidParameterException; /** * * @author timmos */ public class LAFTest { public static void main(String[] args) { try { int snipe = toMinutes(args[0]); int close = toMinutes(args[1]); int bid = -1; for (int i = 2; i < args.length; i++){ int nextBid = toMinutes(args[i]); if (nextBid < close){ close = Math.max(close, nextBid + snipe); bid = nextBid; } else { break; } } System.out.println("Winning bid is " + hhmm(bid)); System.out.println("Final closing time is " + hhmm(close)); } catch (Exception ex){ System.out.println("Wrong arguments. Use <snipe> <closingTime> <lastBidBefore> <bidAfter1> ... <bidAfterN>"); } } private static int toMinutes(String time){ int timeNr = Integer.parseInt(time); int hours = timeNr / 100; int minutes = timeNr % 100; if (0 <= hours && hours <= 23 && 0 <= minutes && minutes <= 59){ return 60 * hours + minutes; } else { throw new InvalidParameterException(); } } private static String hhmm(int minutes){ if (minutes < 0) return "<none>"; String hh = (minutes / 60 < 10 ? "0" : "") + minutes / 60; String mm = (minutes % 60 < 10 ? "0" : "") + minutes % 60; return hh + ":" + mm; } }
Voorbeeldparameters: "15 2100 2056 2114" geeft als output
Winning bid is 20:56
Final closing time is 21:11
Timmos zei:Abe om 20:56. Er komen 15 minuten bij en initiële afsluittijd is 21:00 => nieuwe afsluittijd = 21:11 = max(21:11,21:00). Aangezien BKing daarna pas bood, is dat ongeldig.
Naar mijn mening wordt de nieuwe afsluittijd 21h15..Timmos zei:Abe om 20:56. Er komen 15 minuten bij en initiële afsluittijd is 21:00 => nieuwe afsluittijd = 21:11 = max(21:11,21:00). Aangezien BKing daarna pas bood, is dat ongeldig.
... 'k Zal dit topic dan ook sluiten. Voor dergelijke zaken mag er ook gerapporteerd worden, dan reageert een mod om te bevestigen al dan niet
.