start 380 project5
changes to 380 project 4 changes to 350 project 2 Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
40ac78074b
commit
39ee821f54
174 files changed
+13356
-80
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "LottoBall.h"
|
||||
|
||||
namespace Project4
|
||||
@@ -43,12 +44,19 @@ namespace Project4
|
||||
private: System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem;
|
||||
private: System::Windows::Forms::ToolStripMenuItem^ aboutToolStripMenuItem;
|
||||
private: System::Windows::Forms::GroupBox^ groupBox1;
|
||||
private: System::Windows::Forms::TextBox^ textBox6;
|
||||
private: System::Windows::Forms::TextBox^ textBox5;
|
||||
private: System::Windows::Forms::TextBox^ textBox4;
|
||||
private: System::Windows::Forms::TextBox^ textBox3;
|
||||
private: System::Windows::Forms::TextBox^ textBox2;
|
||||
private: System::Windows::Forms::TextBox^ textBox1;
|
||||
public: System::Windows::Forms::TextBox^ textBox6;
|
||||
private:
|
||||
public: System::Windows::Forms::TextBox^ textBox5;
|
||||
public: System::Windows::Forms::TextBox^ textBox4;
|
||||
public: System::Windows::Forms::TextBox^ textBox3;
|
||||
public: System::Windows::Forms::TextBox^ textBox2;
|
||||
public: System::Windows::Forms::TextBox^ textBox1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private: System::Windows::Forms::Label^ label6;
|
||||
private: System::Windows::Forms::Label^ label5;
|
||||
private: System::Windows::Forms::Label^ label4;
|
||||
@@ -225,6 +233,7 @@ namespace Project4
|
||||
//
|
||||
// radioButton1
|
||||
//
|
||||
this->radioButton1->AutoCheck = false;
|
||||
this->radioButton1->AutoSize = true;
|
||||
this->radioButton1->Location = System::Drawing::Point(51, 86);
|
||||
this->radioButton1->Name = L"radioButton1";
|
||||
@@ -394,7 +403,35 @@ namespace Project4
|
||||
#pragma endregion
|
||||
|
||||
public: List<LottoBall^>^ balls;
|
||||
public: volatile static array<int>^ numbers;
|
||||
public: static array<int>^ numbers;
|
||||
public: System::Void affixNumber(int index, int number)
|
||||
{
|
||||
this->numbers[index] = number;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
textBox5->Text = number.ToString("D2");
|
||||
break;
|
||||
case 1:
|
||||
textBox4->Text = number.ToString("D2");
|
||||
break;
|
||||
case 2:
|
||||
textBox4->Text = number.ToString("D2");
|
||||
break;
|
||||
case 3:
|
||||
textBox3->Text = number.ToString("D2");
|
||||
break;
|
||||
case 4:
|
||||
textBox2->Text = number.ToString("D2");
|
||||
break;
|
||||
case 5:
|
||||
textBox1->Text = number.ToString("D2");
|
||||
break;
|
||||
case 6:
|
||||
textBox6->Text = number.ToString("D2");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
|
||||
{
|
||||
@@ -403,10 +440,10 @@ namespace Project4
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
balls->Add(gcnew LottoBall(1, 75));
|
||||
balls->Add(gcnew LottoBall(1, 75, this));
|
||||
}
|
||||
|
||||
balls->Add(gcnew LottoBall(1, 15));
|
||||
balls->Add(gcnew LottoBall(1, 15, this));
|
||||
}
|
||||
|
||||
private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
|
||||
|
||||
@@ -1,35 +1,40 @@
|
||||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "Form1.h"
|
||||
|
||||
namespace Project4
|
||||
using namespace System;
|
||||
using namespace System::Collections;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Threading::Tasks;
|
||||
using namespace System::Data;
|
||||
using namespace Project4;
|
||||
|
||||
|
||||
public ref class LottoBall
|
||||
{
|
||||
using namespace System;
|
||||
using namespace System::Collections;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Threading::Tasks;
|
||||
using namespace System::Data;
|
||||
|
||||
public ref class LottoBall
|
||||
{
|
||||
public:
|
||||
LottoBall(int minval, int maxval, Form1^ form1);
|
||||
~LottoBall();
|
||||
|
||||
public:
|
||||
LottoBall(int minval, int maxval);
|
||||
~LottoBall();
|
||||
int getCurrentValue();
|
||||
int num;
|
||||
|
||||
int getCurrentValue();
|
||||
int num;
|
||||
System::Void start();
|
||||
System::Void stop();
|
||||
System::Void initThread();
|
||||
|
||||
System::Void start();
|
||||
System::Void stop();
|
||||
private:
|
||||
int minVal;
|
||||
int maxVal;
|
||||
int seedValue;
|
||||
|
||||
private:
|
||||
int minVal;
|
||||
int maxVal;
|
||||
Form1^ formptr;
|
||||
|
||||
bool threadStop;
|
||||
Thread^ thread;
|
||||
System::Void run();
|
||||
Random^ r;
|
||||
|
||||
};
|
||||
bool threadStop;
|
||||
Thread^ thread;
|
||||
System::Void run();
|
||||
|
||||
}
|
||||
};
|
||||
@@ -1,54 +1,59 @@
|
||||
|
||||
#include "LottoBall.h"
|
||||
#include "Form1.h"
|
||||
|
||||
namespace Project4
|
||||
LottoBall::LottoBall(int minval, int maxval, Form1^ form1)
|
||||
{
|
||||
minVal = minval;
|
||||
maxVal = maxval;
|
||||
|
||||
LottoBall::LottoBall(int minval, int maxval)
|
||||
threadStop = false;
|
||||
num = 0;
|
||||
|
||||
formptr = form1;
|
||||
}
|
||||
|
||||
LottoBall::~LottoBall()
|
||||
{
|
||||
thread->Abort();
|
||||
}
|
||||
|
||||
System::Void LottoBall::initThread()
|
||||
{
|
||||
r = gcnew Random();
|
||||
long long seed = 0;
|
||||
for(int i = 0; i < 100; ++i)
|
||||
{
|
||||
minVal = minval;
|
||||
maxVal = maxval;
|
||||
|
||||
threadStop = false;
|
||||
num = 0;
|
||||
thread = gcnew Thread(gcnew ThreadStart(&run));
|
||||
|
||||
seed += r->Next(i, 9999 + i);
|
||||
}
|
||||
r = gcnew Random(seed);
|
||||
thread = gcnew Thread(gcnew ThreadStart(&this->run));
|
||||
}
|
||||
|
||||
LottoBall::~LottoBall()
|
||||
System::Void LottoBall::run()
|
||||
{
|
||||
String^ threadname = Thread::CurrentThread->Name;
|
||||
int id = 0;
|
||||
Int32::TryParse(threadname, id);
|
||||
|
||||
while (!this->threadStop)
|
||||
{
|
||||
thread->Abort();
|
||||
this->num = r->Next(minVal, maxVal);
|
||||
formptr->affixNumber(id, this->num);
|
||||
}
|
||||
}
|
||||
|
||||
System::Void LottoBall::run()
|
||||
{
|
||||
Random^ r = gcnew Random();
|
||||
String^ threadname = Thread::CurrentThread->Name;
|
||||
int id = 0;
|
||||
Int32::TryParse(threadname, id);
|
||||
int LottoBall::getCurrentValue()
|
||||
{
|
||||
return this->num;
|
||||
}
|
||||
|
||||
while (!this->threadStop)
|
||||
{
|
||||
this->num = r->Next(minVal, maxVal);
|
||||
Form1::numbers[id] = this->num;
|
||||
}
|
||||
}
|
||||
|
||||
int LottoBall::getCurrentValue()
|
||||
{
|
||||
return this->num;
|
||||
}
|
||||
|
||||
System::Void LottoBall::start()
|
||||
{
|
||||
this->threadStop = false;
|
||||
thread->Start();
|
||||
}
|
||||
|
||||
System::Void LottoBall::stop()
|
||||
{
|
||||
this->threadStop = true;
|
||||
}
|
||||
System::Void LottoBall::start()
|
||||
{
|
||||
this->threadStop = false;
|
||||
thread->Start();
|
||||
}
|
||||
|
||||
System::Void LottoBall::stop()
|
||||
{
|
||||
this->threadStop = true;
|
||||
}
|
||||
Reference in new issue
Block a user