Category : C++ Source Code
Archive   : CPP_GRPH.ZIP
Filename : LOTTO.CPP

 
Output of file : LOTTO.CPP contained in archive : CPP_GRPH.ZIP
#include "lotto.hpp"

Lotto::Lotto(int x, int y) :

HorizontalSelector(x, y,
"Lotto Ticket Randomizer",
0, 0, "", "", "", "", "", "")

{
// set the object state to inactive
lotto_state = 0;

// don't let any buttons get highlighted
number = -1;
button_selected = &number;

// show the first random picks
Refresh();
}

void Lotto::LeftButtonPressed()
{
// switch to active state, so the Update()
// function takes control
lotto_state = 1;

// hide all pick numbers
Clear();

// highlight all the buttons
for (int i = 0; i < MAX_LOTTO_BUTTONS; i++)
button [i]->Highlight();
}


void Lotto::LeftButtonReleased()
{
// switch to active state, so the Update()
// function takes control
lotto_state = 0;

// look up the next pick series
Refresh();
Display();

// unhighlight all the buttons
for (int i = 0; i < MAX_LOTTO_BUTTONS; i++)
button [i]->UnHighlight();
}

int Lotto::NextPick()
{
// roll the die again
float random = value.NextValue();

// convert to integer in the range (1..49)
return (random * 49) + 1;
}

void Lotto::Clear()
{
// refresh all the pick numbers
for (int i = 0; i < MAX_LOTTO_BUTTONS; i++) {
char string [20];
button [i]->SetLegend("?");
}
Display();
}

void Lotto::Refresh()
{
// refresh all the pick numbers
for (int i = 0; i < MAX_LOTTO_BUTTONS; i++) {
char string [20];
int new_pick = NextPick();
sprintf(string, "%d", new_pick);
button [i]->SetLegend(string);
}
}

void Lotto::MakeSound()
{
// get a random number
float random = value.NextValue();

// convert to frequency in range 100..2000 Hz
int frequency = (random * 1900) + 100;

// make a short sound
EventsHandler->SoundOn(frequency, 30);
}

void Lotto::Update()
{
if (lotto_state == 0) return;
MakeSound();
}


  3 Responses to “Category : C++ Source Code
Archive   : CPP_GRPH.ZIP
Filename : LOTTO.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/