1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#pragma once
#include <ctime>
#include <cstdlib>
#include <string>
namespace Lab6B {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
int randomNumber;
string numberToString;
Form1(void)
{
InitializeComponent();
randomNumber = 0;
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
srand(time(0));
randomNumber = rand() % 100;
itoa (randomNumber,numberToChar,10);
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ lblUserInform;
private: System::Windows::Forms::Button^ btnEvaluate;
private: System::Windows::Forms::Button^ btnTryAgain;
protected:
protected:
private: System::Windows::Forms::Label^ lblTooLow;
private: System::Windows::Forms::Label^ lblTooHigh;
private: System::Windows::Forms::TextBox^ txtUserInput;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->lblUserInform = (gcnew System::Windows::Forms::Label());
this->btnEvaluate = (gcnew System::Windows::Forms::Button());
this->btnTryAgain = (gcnew System::Windows::Forms::Button());
this->lblTooLow = (gcnew System::Windows::Forms::Label());
this->lblTooHigh = (gcnew System::Windows::Forms::Label());
this->txtUserInput = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// lblUserInform
//
this->lblUserInform->AutoSize = true;
this->lblUserInform->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblUserInform->Location = System::Drawing::Point(50, 79);
this->lblUserInform->Name = L"lblUserInform";
this->lblUserInform->Size = System::Drawing::Size(126, 15);
this->lblUserInform->TabIndex = 0;
this->lblUserInform->Text = L"Enter a guess 1 - 100:";
//
// btnEvaluate
//
this->btnEvaluate->Location = System::Drawing::Point(69, 197);
this->btnEvaluate->Name = L"btnEvaluate";
this->btnEvaluate->Size = System::Drawing::Size(187, 47);
this->btnEvaluate->TabIndex = 1;
this->btnEvaluate->Text = L"Press to EVALUATE your guess!";
this->btnEvaluate->UseVisualStyleBackColor = true;
this->btnEvaluate->Click += gcnew System::EventHandler(this, &Form1::btnEvaluate_Click);
//
// btnTryAgain
//
this->btnTryAgain->Location = System::Drawing::Point(69, 286);
this->btnTryAgain->Name = L"btnTryAgain";
this->btnTryAgain->Size = System::Drawing::Size(187, 66);
this->btnTryAgain->TabIndex = 2;
this->btnTryAgain->Text = L"Press to CLEAR your guess and TRY AGAIN!";
this->btnTryAgain->UseVisualStyleBackColor = true;
this->btnTryAgain->Visible = false;
this->btnTryAgain->Click += gcnew System::EventHandler(this, &Form1::btnTryAgain_Click);
//
// lblTooLow
//
this->lblTooLow->AutoSize = true;
this->lblTooLow->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblTooLow->Location = System::Drawing::Point(66, 125);
this->lblTooLow->Name = L"lblTooLow";
this->lblTooLow->Size = System::Drawing::Size(60, 15);
this->lblTooLow->TabIndex = 3;
this->lblTooLow->Text = L"Too Low!!";
this->lblTooLow->Visible = false;
//
// lblTooHigh
//
this->lblTooHigh->AutoSize = true;
this->lblTooHigh->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblTooHigh->Location = System::Drawing::Point(212, 125);
this->lblTooHigh->Name = L"lblTooHigh";
this->lblTooHigh->Size = System::Drawing::Size(63, 15);
this->lblTooHigh->TabIndex = 4;
this->lblTooHigh->Text = L"Too High!!";
this->lblTooHigh->Visible = false;
//
// txtUserInput
//
this->txtUserInput->Location = System::Drawing::Point(208, 74);
this->txtUserInput->MaxLength = 3;
this->txtUserInput->Name = L"txtUserInput";
this->txtUserInput->Size = System::Drawing::Size(100, 20);
this->txtUserInput->TabIndex = 5;
this->txtUserInput->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::ActiveCaption;
this->ClientSize = System::Drawing::Size(337, 398);
this->Controls->Add(this->txtUserInput);
this->Controls->Add(this->lblTooHigh);
this->Controls->Add(this->lblTooLow);
this->Controls->Add(this->btnTryAgain);
this->Controls->Add(this->btnEvaluate);
this->Controls->Add(this->lblUserInform);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void btnEvaluate_Click(System::Object^ sender, System::EventArgs^ e) {
this->btnTryAgain->Visible = true;
this->btnEvaluate->Visible = false;
this->btnTryAgain->Focus();
this->BackColor = System::Drawing::SystemColors::HotTrack;
}
private: System::Void btnTryAgain_Click(System::Object^ sender, System::EventArgs^ e) {
this->btnEvaluate->Visible = true;
this->btnTryAgain->Visible = false;
this->txtUserInput->Clear();
this->btnEvaluate->Focus();
this->BackColor = System::Drawing::SystemColors::ActiveCaption;
}
};
}
|