Oxygene for Java version of RockPaperScissors
Pascal version by Hasaan Ausat: Y12 Age ~16
We supply below the Oxygene for Java code (in rps.pas) adapted from the original Pascal, a slimmed-down xml project file (rps.oxygene) to be used by the Oxygene compiler following the command line instruction msbuild rps.oxygene. Afterwards, run the program with java -jar rps.jar. Alternatively, open the project file in Visual Studio and click on the green arrow.
We copied the file to a memory stick, plugged the memory stick into the Pi (with automatic USB mounting enabled), and typed commands as shown in this screenshot.

Rock Paper Scissors on the Pi
This conversion shows how to use System.out.println instead of writeln and System.in.read instead of read in Oxygene for Java console applications. It also demonstrates the use of Maths.random.
Oxygene for Java code of rps.pas
namespace RockPaperScissors; { Copyright (c) 2010 Hasaan Ausat 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 implementation var playcount, playercount, compcount, tiecount, number, answer : Integer; input_chars : array[0 .. 3] of SByte; begin writeln('|-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*|'); writeln('| |'); writeln('| WELCOME TO ROCK PAPER SCISSORS |'); writeln('| |'); writeln('|*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-|'); writeln; playcount := 0; compcount := 0; playercount := 0; tiecount := 0; repeat writeln('Rock is 0, Paper is 1, Scissors is 2'); writeln; System.in.read(input_chars); number := input_chars[0] - 48; // Zero is ASCII 48 if number > 2 then begin repeat writeln('Rock is 0, Paper is 1, Scissors is 2'); System.in.read(input_chars); number := input_chars[0] - 48; until number < 3; end; answer := Integer(Math.random() * 3); //answer will be 0, 1, or 2 writeln; writeln('I have picked ' + answer.ToString); writeln; if (answer = 0) and (number = 0) then begin writeln('|-------|'); writeln('| Tie!! |'); writeln('|-------|'); writeln; playcount := playcount + 1; tiecount := tiecount + 1; end; if (answer = 0) and (number = 1) then begin writeln('|------------|'); writeln('| You win :) |'); writeln('|------------|'); writeln; playcount := playcount + 1; playercount := playercount + 1; end; if (answer = 1) and (number = 0) then begin writeln('|--------------|'); writeln('| You lose :( |'); writeln('|--------------|'); writeln; playcount := playcount + 1; compcount := compcount + 1; end; if (answer = 1) and (number = 1) then begin writeln('|-------|'); writeln('| Tie!! |'); writeln('|-------|'); writeln; playcount := playcount + 1; tiecount := tiecount + 1; end; if (answer = 1) and (number = 2) then begin writeln('|------------|'); writeln('| You win :) |'); writeln('|------------|'); writeln; playercount := playercount + 1; playcount := playcount + 1; end; if (answer = 2) and (number = 1) then begin writeln('|--------------|'); writeln('| You lose :( |'); writeln('|--------------|'); writeln; playcount := playcount + 1; compcount := compcount + 1; end; if (answer = 2) and (number = 2) then begin writeln('|-------|'); writeln('| Tie!! |'); writeln('|-------|'); writeln(); playcount := playcount + 1; tiecount := tiecount + 1; end; if (answer = 2) and (number = 0) then begin writeln('|------------|'); writeln('| You win :) |'); writeln('|------------|'); writeln; playercount := playercount + 1; playcount := playcount + 1; end; if (answer = 0) and (number = 2) then begin writeln('|--------------|'); writeln('| You lose :( |'); writeln('|--------------|'); writeln; playcount := playcount + 1; compcount := compcount + 1; end; writeln('Would you like to play again? y/n'); writeln; System.in.read(input_chars); until input_chars[0] = 110; //ASCII n = 110 writeln('You have played ' + playcount.toString + ' times'); writeln; writeln('You won ' + playercount.toString + ' times'); writeln; writeln('You lost ' + compcount.toString + ' times'); writeln; writeln('We drew ' + tiecount.toString + ' times'); writeln; System.in.read; if compcount < playercount then begin writeln(' _'); writeln(' ( (('); writeln(' \ =\'); writeln(' __\_ `-\'); writeln('(____))( \----'); writeln('(____)) _'); writeln('(____))'); writeln('(____))____/----'); writeln; end; if compcount > playercount then begin writeln(' _____'); writeln('((____ \----'); writeln('((____'); writeln('((____'); writeln('((____ ----'); writeln(' / /'); writeln(' (_(('); writeln; end; if compcount = playercount then begin writeln(' _'); writeln(' ( (('); writeln(' \ =\'); writeln(' __\_ `-\'); writeln('(____))( \----'); writeln('(____)) _'); writeln('(____))'); writeln('(____))____/----'); writeln(' _____'); writeln('((____ \----'); writeln('((____'); writeln('((____'); writeln('((____ ----'); writeln(' / /'); writeln(' / =/'); writeln(' (_(('); writeln(); end; writeln('Goodbye, Hope you had fun!!!!!!!!!'); writeln; System.in.read; writeln('RockPaperScissors (c) 2009 - Huskimo'); System.in.read; end.
Project file
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <ItemGroup> <Reference Include="rt.jar" /> </ItemGroup> <ItemGroup> <Compile Include="rps.pas" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\RemObjects Software\Oxygene\RemObjects.Oxygene.Cooper.targets" /> </Project>