|
From: <pe...@us...> - 2003-11-21 04:42:49
|
Update of /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/totalizers/dumb
In directory sc8-pr-cvs1:/tmp/cvs-serv10206/src/java/org/neuclear/bet/totalizers/dumb
Modified Files:
DumbBetEvent.java DumbOutcome.java DumbTotalizer.java
Log Message:
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Index: DumbBetEvent.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/totalizers/dumb/DumbBetEvent.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DumbBetEvent.java 20 Sep 2003 23:19:22 -0000 1.1.1.1
--- DumbBetEvent.java 21 Nov 2003 04:42:45 -0000 1.2
***************
*** 10,16 ****
* Time: 4:31:43 PM
*/
! public class DumbBetEvent extends TotalizerEvent {
! public DumbBetEvent(DumbTotalizer tote, BettingEvent event) {
super(tote, event);
}
--- 10,16 ----
* Time: 4:31:43 PM
*/
! public final class DumbBetEvent extends TotalizerEvent {
! public DumbBetEvent(final DumbTotalizer tote, final BettingEvent event) {
super(tote, event);
}
***************
*** 26,34 ****
*/
! public double getTotal() {
return total * (1 - getTotalizer().getCommissionRate());
}
! protected void increaseTotal(double amount) {
total += amount;
}
--- 26,34 ----
*/
! public final double getTotal() {
return total * (1 - getTotalizer().getCommissionRate());
}
! protected final void increaseTotal(final double amount) {
total += amount;
}
***************
*** 62,66 ****
! public static long SEED = 1231423425;
private double total;
--- 62,66 ----
! public static final long SEED = 1231423425;
private double total;
Index: DumbOutcome.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/totalizers/dumb/DumbOutcome.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DumbOutcome.java 20 Sep 2003 23:19:22 -0000 1.1.1.1
--- DumbOutcome.java 21 Nov 2003 04:42:45 -0000 1.2
***************
*** 17,22 ****
* Time: 4:32:49 PM
*/
! public class DumbOutcome implements BettableOutcome {
! public DumbOutcome(DumbBetEvent event, String id, String title) {
this.id = id;
this.title = title;
--- 17,22 ----
* Time: 4:32:49 PM
*/
! public final class DumbOutcome implements BettableOutcome {
! public DumbOutcome(final DumbBetEvent event, final String id, final String title) {
this.id = id;
this.title = title;
***************
*** 25,33 ****
}
! double getPool() {
return pool;
}
! public double getOdds() {
if (((DumbBetEvent) getEvent()).getTotal() == 0 || getPool() == 0)
return 0;
--- 25,33 ----
}
! final double getPool() {
return pool;
}
! public final double getOdds() {
if (((DumbBetEvent) getEvent()).getTotal() == 0 || getPool() == 0)
return 0;
***************
*** 35,53 ****
}
! public synchronized String bet(double amount) throws BettingEventExpired {
if (getEvent().isClosed())
throw new BettingEventExpired("Betting has closed for event: " + getEvent().getId());
pool += amount;
((DumbBetEvent) getEvent()).increaseTotal(amount);
! String betid = new BigInteger(512, new Random()).toString(36);
bets.put(betid, new Double(amount));
return betid;
}
! public int hashCode() {
return getId().hashCode(); //To change body of overriden methods use Options | File Templates.
}
! public boolean equals(Object object) {
if (object instanceof DumbOutcome)
return ((DumbOutcome) object).getId().equals(getId()) && (((DumbBetEvent) getEvent()).equals(((DumbOutcome) object).getEvent()));
--- 35,53 ----
}
! public final synchronized String bet(final double amount) throws BettingEventExpired {
if (getEvent().isClosed())
throw new BettingEventExpired("Betting has closed for event: " + getEvent().getId());
pool += amount;
((DumbBetEvent) getEvent()).increaseTotal(amount);
! final String betid = new BigInteger(512, new Random()).toString(36);
bets.put(betid, new Double(amount));
return betid;
}
! public final int hashCode() {
return getId().hashCode(); //To change body of overriden methods use Options | File Templates.
}
! public final boolean equals(final Object object) {
if (object instanceof DumbOutcome)
return ((DumbOutcome) object).getId().equals(getId()) && (((DumbBetEvent) getEvent()).equals(((DumbOutcome) object).getEvent()));
***************
*** 55,78 ****
}
! public Iterator listBets() {
return bets.keySet().iterator();
}
! public String getId() {
return id;
}
! public BettingEvent getEvent() {
return event;
}
! public String getTitle() {
return title;
}
private double pool;
! private String id;
! private String title;
! private BettingEvent event;
! private Map bets;
}
--- 55,78 ----
}
! public final Iterator listBets() {
return bets.keySet().iterator();
}
! public final String getId() {
return id;
}
! public final BettingEvent getEvent() {
return event;
}
! public final String getTitle() {
return title;
}
private double pool;
! private final String id;
! private final String title;
! private final BettingEvent event;
! private final Map bets;
}
Index: DumbTotalizer.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/totalizers/dumb/DumbTotalizer.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DumbTotalizer.java 20 Sep 2003 23:19:22 -0000 1.1.1.1
--- DumbTotalizer.java 21 Nov 2003 04:42:45 -0000 1.2
***************
*** 14,19 ****
* Time: 3:49:49 PM
*/
! public class DumbTotalizer implements Totalizer, ResultSource, ResultListener, NewEventListener {
! public DumbTotalizer(Double commissionRate) {
events = new HashMap();
results = new LinkedList();
--- 14,19 ----
* Time: 3:49:49 PM
*/
! public final class DumbTotalizer implements Totalizer, ResultSource, ResultListener, NewEventListener {
! public DumbTotalizer(final Double commissionRate) {
events = new HashMap();
results = new LinkedList();
***************
*** 22,51 ****
}
! public void addEvent(BettingEvent event) {
events.put(event.getId(), event);
}
! public void addResultListener(ResultListener result) {
if (result != null)
results.add(result);
}
! public Iterator listEvents() {
return events.values().iterator(); //To change body of implemented methods use Options | File Templates.
}
! public BettingEvent getEvent(String id) {
return (BettingEvent) events.get(id); //To change body of implemented methods use Options | File Templates.
}
! public Date getCurrentTime() {
return new Date(); //To change body of implemented methods use Options | File Templates.
}
! public double getCommissionRate() {
return commissionRate; //To change body of implemented methods use Options | File Templates.
}
! public BettableOutcome makeBettable(EventOutcome outcome) {
return null;
}
--- 22,51 ----
}
! public final void addEvent(final BettingEvent event) {
events.put(event.getId(), event);
}
! public final void addResultListener(final ResultListener result) {
if (result != null)
results.add(result);
}
! public final Iterator listEvents() {
return events.values().iterator(); //To change body of implemented methods use Options | File Templates.
}
! public final BettingEvent getEvent(final String id) {
return (BettingEvent) events.get(id); //To change body of implemented methods use Options | File Templates.
}
! public final Date getCurrentTime() {
return new Date(); //To change body of implemented methods use Options | File Templates.
}
! public final double getCommissionRate() {
return commissionRate; //To change body of implemented methods use Options | File Templates.
}
! public final BettableOutcome makeBettable(final EventOutcome outcome) {
return null;
}
***************
*** 55,63 ****
* @param outcome
*/
! public void win(EventOutcome outcome) throws LowlevelLedgerException {
events.remove(outcome.getEvent());
! Iterator iter = results.iterator();
while (iter.hasNext()) {
! ResultListener listener = (ResultListener) iter.next();
listener.win(outcome);
}
--- 55,63 ----
* @param outcome
*/
! public final void win(final EventOutcome outcome) throws LowlevelLedgerException {
events.remove(outcome.getEvent());
! final Iterator iter = results.iterator();
while (iter.hasNext()) {
! final ResultListener listener = (ResultListener) iter.next();
listener.win(outcome);
}
***************
*** 69,77 ****
* @param outcome
*/
! public void scratch(EventOutcome outcome) throws LowlevelLedgerException {
outcome.getEvent().scratch(outcome);
! Iterator iter = results.iterator();
while (iter.hasNext()) {
! ResultListener listener = (ResultListener) iter.next();
listener.scratch(outcome);
}
--- 69,77 ----
* @param outcome
*/
! public final void scratch(final EventOutcome outcome) throws LowlevelLedgerException {
outcome.getEvent().scratch(outcome);
! final Iterator iter = results.iterator();
while (iter.hasNext()) {
! final ResultListener listener = (ResultListener) iter.next();
listener.scratch(outcome);
}
***************
*** 83,91 ****
* @param event
*/
! public void cancelEvent(BettingEvent event) throws LowlevelLedgerException {
events.remove(event);
! Iterator iter = results.iterator();
while (iter.hasNext()) {
! ResultListener listener = (ResultListener) iter.next();
listener.cancelEvent(event);
}
--- 83,91 ----
* @param event
*/
! public final void cancelEvent(final BettingEvent event) throws LowlevelLedgerException {
events.remove(event);
! final Iterator iter = results.iterator();
while (iter.hasNext()) {
! final ResultListener listener = (ResultListener) iter.next();
listener.cancelEvent(event);
}
***************
*** 93,100 ****
! private Map events;
! private List results;
private double commissionRate = 0.15;
! private Timer timer;
}
--- 93,100 ----
! private final Map events;
! private final List results;
private double commissionRate = 0.15;
! private final Timer timer;
}
|