Oxygen for Java Version of Roulette
Pascal version by Ayotunde: Y9 Age ~14
Introduction
This Oxygene for Java version outputs Java bytecote in a .jar file. The bytecode runs in a Java Virtual Machine on a PC and on the Pi and should run on any platform with the Java Development Kit (JDK) installed. This screenshot shows the program running on the Pi.

Roulette on the Pi
We used the command sudo apt-get install openjdk-6-jdk to install a version of the SDK. The java executable installs to the /usr/bin folder. We created the directory Oxygene with the command mkdir Oxygene then copied roulette.jar to that directory. Finally, the command /usr/bin/java -jar Oxygene/roulette.jar executed the program as shown.
In Oxygene for Java, regardless of the type of input, you must first use an array of TByte to store the keyed-in characters. We found it necessary to initialise the array of TByte (to represent spaces) before each input, otherwise there could be corruption from additional characters remaining from previous longer inputs. The alternative is to store then use the number of characters entered for each input, as shown in our tutorial on keyboard input.
The Program
namespace roulette; { Copyright (c) 2012 Ayotunde Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License, as described at http://www.apache.org/licenses/ and http://www.pp4s.co.uk/licenses/ Converted to Oxygene for Java by PPS. } interface var endgame, number, redblack, bet, wheelroll, decide, bank, deposit, take, redblackchoose : Integer; total, wager1, wager2, maxbet, minbet : Double; input_chars : array[0 .. 6] of SByte := [32, 32, 32, 32, 32, 32, 32]; str_temp : String; implementation uses java.util; method betS; begin Thread.sleep(500); writeln('You can bet up to three quarters of your current total.'); Thread.sleep(500); writeln('How much money do you want to bet, in pounds?'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); wager1 := Float.valueOf(str_temp.trim); maxbet := total * 0.75; minbet := 6; if wager1 >= (maxbet + 1) then begin writeln('That is too much. You want to be able to buy food, no?'); end else if wager1 <= (minbet - 1) then begin writeln('That is too little. This is for-profit business, you know.'); end; end; method betR; begin writeln('You can bet up to half of your current total.'); Thread.sleep(500); writeln('How much you want to bet?'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); wager2 := Float.valueOf(str_temp.trim); maxbet := total * 0.5; minbet := 6; if wager2 >= (maxbet + 1) then begin writeln('That is too much. You want to be able to buy food, no?'); end else if wager2 <= (minbet - 1) then begin writeln('That is too little. This is for-profit business, you know.'); end; end; begin var random : Random := new Random; wager1 := 999; bank := 50; endgame := 5667; total := 100; writeln('Velcome. You vant to lose some cash?'); Thread.sleep(500); repeat writeln('You can place bet on either number or a colour, red or black.'); Thread.sleep(500); System.out.printf('You have %.2f pounds. Try not to lose it too fast!%n', total); Thread.sleep(500); writeln('1= Bet on a number.'); writeln('2= Bet on red or black.'); writeln('3= Vithdraw some cash.'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); bet := Integer.valueOf(str_temp.trim); if bet = 1 then begin repeat betS; until (wager1 < (maxbet + 1)) and (wager1 > (minbet - 1)); if (wager1 < (maxbet + 1)) and (wager1 > (minbet - 1)) then begin writeln('Bet on a number. It can be anything from 1 to 37.'); wheelroll := random.nextInt(37) + 1; input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); number := Integer.valueOf(str_temp.trim); if number = wheelroll then begin writeln('Hey, you hit the jackpot! You guessed right!'); total := total + 30 * wager1; end else begin writeln('Sorry, that is incorrect....hehehe...'); total := total - wager1; end; end; //if wager1 end; //bet = 1 if bet = 2 then begin repeat betR; until (wager2 < (maxbet + 1)) and (wager2 > (minbet - 1)); if (wager2 < (maxbet + 1)) and (wager2 > (minbet - 1)) then begin writeln('Bet on 1 (Red) or 2 (Black).'); redblack := random.nextInt(2) + 1; //Redblack can either be 2 or 1. input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); redblackchoose := Integer.valueOf(str_temp.trim); if (redblack = 1) and (redblackchoose = 1) then begin writeln('It came out red. You got lucky this time.'); total := total + wager2; end else if (redblack = 2) and (redblackchoose = 2) then begin writeln('It seems to be black. Fortune has smiled on you.'); total := total + wager2; end else begin writeln('Unlucky, you were wrong.'); total := total - wager2; end; end; end //bet = 2 else if bet = 3 then begin repeat writeln('Your current balance is ' + bank.toString + ' pounds.'); Thread.sleep(100); writeln('How much you want to vithdraw?'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); take := Integer.valueOf(str_temp.trim); if take > bank then writeln('Hehehe, nice try, kiddo.'); until take <= bank; bank := bank - take; total := total + take; writeln('Your balance is now ' + bank.toString + ' pounds.'); end; //bet = 3 writeln('Come on, play Roulette.'); writeln('Want to try again?'); writeln('1= Have another go.'); writeln('2= Quit the game.'); writeln('3= Continue and bank some cash.'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); decide := Integer.valueOf(str_temp.trim); if decide = 2 then begin writeln('........'); endgame := 1789; end else if decide = 3 then begin writeln('How much cash you vant to bank?'); input_chars := [32, 32, 32, 32, 32, 32, 32]; System.in.read(input_chars); str_temp := new String(input_chars); deposit := Integer.valueOf(str_temp.trim); total := total - deposit; bank := bank + deposit; writeln('Your current balance is ' + bank.toString + ' pounds.'); Thread.sleep(100); end; if decide = 1 then begin Thread.sleep(100); end; until (total < minbet * 2) or (total > 999) or (endgame = 1789); if total < minbet * 2 then begin System.out.printf('You have %.2f pounds remaining.%n', total); writeln('You have not got enough money to keep playing. Get out!'); Thread.sleep(2000); end; if endgame = 1789 then begin System.out.printf('You have %.2f pounds remaining.%n', total); if (total + bank) < 150 then begin writeln('Thank you for vasting money. Please show yourself out.'); end; Thread.sleep(2000); end; end.