Ryoma, on 06 July 2010 - 12:56 PM, said:

this is a ss when the game starts
Sry for dubble posting but i wanted to gave you guys the exe file
The database is in there to it is required
Risico
you can donwload it here
Posted 06 July 2010 - 02:00 PM
Ryoma, on 06 July 2010 - 12:56 PM, said:

Posted 07 July 2010 - 09:59 PM
class Roshambo
def initialize
@choice = 0
@roshambo = ["paper", "rock", "scissors"]
end
def set_roshambo(choice)
@choice = choice
end
def get_roshambo
return @roshambo.at(@choice)
end
end
class Player
attr_accessor :name, :roshambo
def initialize name
@name = name
@roshambo = Roshambo.new
end
def set_roshambo choice
@roshambo.set_roshambo(choice)
end
def get_roshambo
return @roshambo.get_roshambo
end
def compare(player2)
if @roshambo.get_roshambo == player2.get_roshambo
puts "It's a tie!"
elsif (@roshambo.get_roshambo == "paper" and player2.get_roshambo == "scissors") or
(@roshambo.get_roshambo == "rock" and player2.get_roshambo == "paper") or
(@roshambo.get_roshambo == "scissors" and player2.get_roshambo == "rock")
puts "You Lose! :(/>"
else
puts "You Win!! :D/>"
end
end
end
class Opponent < Player
def initialize
@name = "Fred"
@roshambo = Roshambo.new
end
def set_roshambo
choice = rand(3)
@roshambo.set_roshambo(choice)
end
end
jon = Player.new("Jon")
opp = Opponent.new
puts "Make your choice \n1. Paper\n2. Rock\n3. Scissors\n<1,2, or 3>\n"
choice = gets.chomp.to_i - 1
jon.set_roshambo(choice)
opp.set_roshambo
puts "You chose: #{jon.get_roshambo}"
puts "#{opp.name} chose: #{opp.get_roshambo}"
puts jon.compare(opp)
puts "Thanks for playing!"
Posted 10 July 2010 - 09:34 AM
Posted 10 July 2010 - 11:17 AM
Posted 11 July 2010 - 09:01 PM

Week24DIC52WeeksOfCode(You'llNeedNAudio).zip (152.77K)
This post has been edited by laserbeak43: 11 July 2010 - 09:03 PM
Posted 12 July 2010 - 05:04 AM
This post has been edited by Shane Hudson: 12 July 2010 - 05:06 AM
Posted 17 August 2010 - 01:49 PM
Posted 17 August 2010 - 08:43 PM
logicandchaos, on 17 August 2010 - 12:49 PM, said:
Posted 18 August 2010 - 07:24 PM
public class Simon
{
public List<int> Choices { get; private set; }
public int Level { get; private set; }
private Random random { get; set; }
private Timer timer { get; set; }
public Simon()
{
this.Level = 1;
random = new Random();
}
public void Start()
{
bool isRunning = true;
Console.WriteLine("You are Level " + this.Level + ". Press <Enter> to begin");
Console.ReadLine();
while (isRunning)
{
this.Setup();
this.ShowChoices();
if (isWinner())
{
Console.WriteLine("You got them all right! \nYou've gained a level.");
LevelUp();
Console.WriteLine("Level: " + this.Level + "\nPress Enter to Begin Next Round");
Console.ReadLine();
}
else
{
Console.WriteLine("You Lose! \n The correct choices were:");
foreach (int choice in Choices)
{
Console.Write(choice + " ");
}
Console.WriteLine("\nWould you like to try again? < Y or N >");
string response = Console.ReadLine();
if (response != "Y" && response != "y") isRunning = false;
}
}
}
private bool isWinner()
{
List<int> pChoices = playerChoices();
int i=0;
foreach (int choice in pChoices)
{
if (choice != Choices[i++]) return false;
}
return true;
}
private void Setup()
{
this.Choices = new List<int>();
this.timer = new Timer(2500 - (this.Level * 250));
for (int i=0; i<this.Level + 3; i++)
{
int num = random.Next(4)+1;
Choices.Add(num);
}
}
private void LevelUp()
{
this.Level++;
}
private void ShowChoices()
{
int i = 0;
timer.Execute(delegate(){
Console.Clear();
if (i != Choices.Count)
Console.WriteLine(Choices[i++]);
else
timer.End();
});
}
public List<int> playerChoices()
{
List<int> pChoices = new List<int>();
Console.WriteLine("Enter the " + Choices.Count + " numbers in the correct order");
for (int i=0; i < Choices.Count; i++)
{
Console.Write("Choice " + (i+1) + ":");
pChoices.Add(Convert.ToInt32(Console.ReadLine()));
}
return pChoices;
}
}
public class Timer
{
public int Interval { get; set; }
public int Duration { get; set; }
private DateTime end { get; set; }
private DateTime next { get; set; }
private bool isRunning { get; set; }
/***************************************
Default Constructor - will just execute the code
block or function once and quit
***************************************/
public Timer()
{
Interval = 0;
Duration = 0;
}
/***************************************
Constructor - Executes the function once per
interval until End() is called
***************************************/
public Timer(int interval)
{
this.Interval = interval;
if (this.Interval < 250) this.Interval = 250;
this.Duration = 0;
}
/***************************************
Constructor - Executes the function once per
interval until duration is reached
***************************************/
public Timer(int interval, int duration)
{
this.Interval = interval;
if (this.Interval < 250) this.Interval = 250;
this.Duration = duration;
}
/***************************************
Execute Method - Executes the given Action
***************************************/
public void Execute(Action action)
{
if (this.Interval > 0)
{
this.getEnd();
this.getNext();
this.isRunning = true;
while (DateTime.Now != this.end && this.isRunning)
{
if (DateTime.Now == this.next)
{
action.Invoke();
this.getNext();
}
}
}
else
action.Invoke();
}
/***************************************
Method Next() - used by the next property to get
the time of the next interval
***************************************/
private void getNext()
{
if (this.Interval > 0)
this.next = DateTime.Now.AddMilliseconds(this.Interval);
}
/***************************************
Method End() - gets the End Time and stores it
in the end property
***************************************/
private void getEnd()
{
if (this.Duration > 0)
this.end = DateTime.Now.AddMilliseconds(this.Duration); // if duration is > 0 set a duration
else
this.end = new DateTime(2000,1,1); // if duration <= 0 create a time that can't be reached
}
/***************************************
Method End() - manually stop the timer
***************************************/
public void End()
{
this.isRunning = false;
}
}
public class SimonMain
{
public static void Main(string[] args)
{
Simon simon = new Simon();
simon.Start();
Console.ReadLine();
}
}
This post has been edited by Nakor: 18 August 2010 - 07:43 PM
