Commits

Alex Kulikoff committed 296d5ee

напиши функцию isBad и почини баг в кнопке Дать

Comments (0)

Files changed (12)

src/Banker/Banker.suo

Binary file modified.

src/Banker/Banker/Form1.cs

             InitializeComponent();
         }
 
-        
 
+        #region Глобальные переменные
         Stack<int> blockProc=new Stack<int>(); // стек содержащий индексы выполненых процессов
         Stack<int> blockRes = new Stack<int>();  // стек содержащий индексы ресурсов выполненых процессов
 
 
         Random rnd = new Random(); // генератор случайных чисел
 
-        string GUID = "aa645ec4-0781-4a99-9e0d-b1006f33b866";
-
     static  public  int level=1;
      static  public int variant=1;
 
         string name = "";
         string group = "";
 
-        
+        #endregion
 
-        
+
 
         class Var
         {
         Var[] var2 = new Var[9] 
         {   new Var(new int[3,5] { {3, 6, 4, 5,0},{2, 5, 3, 4,0},{0,0,0,0,0} }, new int[]{6, 5,0}),
             new Var(new int[3,5] { {5, 6, 4, 5,0},{3, 5, 4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
-            new Var(new int[3,5] { {3, 5, 4, 6,0},{5, 1, 5, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
-            new Var(new int[3,5] { {4, 5, 6, 3,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
-            new Var(new int[3,5] { {2, 6, 6, 5,0},{4, 1, 4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
-            new Var(new int[3,5] { {2, 5, 6, 6,0},{5, 1, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
-            new Var(new int[3,5] { {2, 6, 6, 5,0},{5, 0 ,4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {3, 6, 4, 5,0},{5, 1, 5, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {4, 6, 5, 3,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 6, 5, 5,0},{4, 1, 4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 6, 5, 6,0},{5, 1, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 6, 5, 5,0},{5, 0 ,4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
             new Var(new int[3,5] { {3, 5, 4, 5,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
             new Var(new int[3,5] { {3, 5, 4, 5,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
             
             
         };
         #endregion
+
         void level1(Var var) // Первый уровень, var - вариант задания
         {
             cur = var;
             reSet();
             genQ();
 
-        }
-        void copy(int[,] x, int[,] y) 
-        {
-            for (int i = 0; i < 3; i++)
-                for (int j = 0; j < 5; j++)
-                    x[i, j] = y[i, j];
-        }
+        } 
         void level2(Var var) // Второй уровень, var - вариант задания
         {
             cur = var;
             reSet();
             genQ();
         }
+
         void genOut() // генератор выходного файла
         {
             StreamWriter of = new StreamWriter("banker.out");
         
         }
 
+        void copy(int[,] x, int[,] y)
+        {
+            for (int i = 0; i < 3; i++)
+                for (int j = 0; j < 5; j++)
+                    x[i, j] = y[i, j];
+        }
+
         public string MD5(string instr)
         {
             string strHash = string.Empty;
             switch (level) 
             {
                 case 1:  do { proc = rnd.Next(1, 4); res = 1; } while (isBlock()&&!isOver()); label1.Text = "Процесс " + proc + " просит ресурс " + res; break;
-                case 2: do { proc = rnd.Next(1, 5); res = rnd.Next(1, 3); } while (isBlock() && !isOver()); label1.Text = "Процесс " + proc + " просит ресурс " + res; 
+                case 2: do { proc = rnd.Next(1, 3); res = rnd.Next(1, 3); } while (isBlock() && !isOver()&&isBad()); label1.Text = "Процесс " + proc + " просит ресурс " + res; 
+                   
                    
                     break;
                 case 3: do { proc = rnd.Next(1, 6); res = rnd.Next(1, 4); } while (isBlock() && !isOver()); label1.Text = "Процесс " + proc + " просит ресурс " + res; break;
             if (isOver()) { label1.Text = ""; label8.Text = ""; groupBox1.Hide();  }
         }
 
+        #region Логические функции
+
         bool isBlock() 
         {
             return isBlock(this.proc, this.res);
                 return k;
         }
 
-        private void button3_Click(object sender, EventArgs e)
+        bool isBad()
         {
-            blockProc.Clear(); blockRes.Clear();
+            return isBlock();
+        }
 
-            groupBox1.Show();
-            groupBox1.Enabled = true;
-            
+        bool isOver()
+        {
+            switch (level)
+            {
+                case 1: if (max[0, 0] == 0 && max[0, 1] == 0 && max[0, 2] == 0) return true; break;
+                case 2: if (max[0, 0] == 0 && max[0, 1] == 0 && max[0, 2] == 0 && max[1, 0] == 0 && max[1, 1] == 0 && max[1, 2] == 0 && max[0, 3] == 0 && max[1, 3] == 0) return true; break;
+                case 3: return true; break;
 
-            
+            }
+            return false;
+        }
 
-            if (radioButton1.Checked)
-            {
-                if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
-                {
-                    family = textBox1.Text; textBox1.ReadOnly = true;
-                    name = textBox2.Text; textBox2.ReadOnly = true;
-                    group = textBox3.Text; textBox3.ReadOnly = true;
-                }
-
-                else { MessageBox.Show("Введите регистрационную информацию", "Ошибка"); return; }
-                blck();
-                level1(var1[rnd.Next(1,4)]);
-                
-            }
-            else 
-            {
-                Form2 f2 = new Form2();
-               
-                f2.ShowDialog();
-                blck();
-                switch (level) 
-                {
-                    case 1: level1(var1[variant]); break;
-                    case 2: level2(var2[variant]); break;
-                    case 3: level3(var3[variant]); break;
-                }
-                
-            }
-            
-        }
+        #endregion
 
         void blck() 
         {
             for (int i = 1; i <= 3; i++) table2[ i,0].Value = rezerv[i - 1];
         }
 
+        #region Обработка событий
+
         private void Form1_Load(object sender, EventArgs e)
         {
            table1.Rows.Add("Процесс1", 0, 0, 0, 0, 0, 0);
             genQ();
         }
 
+        private void button3_Click(object sender, EventArgs e)
+        {
+            blockProc.Clear(); blockRes.Clear();
+
+            groupBox1.Show();
+            groupBox1.Enabled = true;
+
+
+
+
+            if (radioButton1.Checked)
+            {
+                if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
+                {
+                    family = textBox1.Text; textBox1.ReadOnly = true;
+                    name = textBox2.Text; textBox2.ReadOnly = true;
+                    group = textBox3.Text; textBox3.ReadOnly = true;
+                }
+
+                else { MessageBox.Show("Введите регистрационную информацию", "Ошибка"); return; }
+                blck();
+                level1(var1[rnd.Next(1, 4)]);
+
+            }
+            else
+            {
+                Form2 f2 = new Form2();
+
+                f2.ShowDialog();
+                blck();
+                switch (level)
+                {
+                    case 1: level1(var1[variant]); break;
+                    case 2: level2(var2[variant]); break;
+                    case 3: level3(var3[variant]); break;
+                }
+
+            }
+
+        }
+
+        #endregion
+
         private void nextLevel()
         {
             switch (level) 
             }
         }
 
-        private bool isOver() 
-        {   
-            switch (level) 
-            {
-                case 1: if (max[0, 0] == 0 && max[0, 1] == 0 && max[0, 2] == 0) return true; break;
-                case 2: if (max[0, 0] == 0 && max[0, 1] == 0 && max[0, 2] == 0 && max[1, 0] == 0 && max[1, 1] == 0 && max[1, 2] == 0 && max[0, 3] == 0 && max[1, 3] == 0) return true; break;
-                case 3: return true; break;
-               
-            }
-            return false;
-        }
+        
        
 
         private void cmp()

src/Banker/Banker/Form2.Designer.cs

             this.button1.TabIndex = 0;
             this.button1.Text = "Принять";
             this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
             // domainUpDown1
             // 

src/Banker/Banker/Form2.cs

 
         private void domainUpDown2_SelectedItemChanged(object sender, EventArgs e)
         {
-            Form1.variant = Convert.ToInt16(domainUpDown2.SelectedItem);
+            Form1.variant = Convert.ToInt16(domainUpDown2.SelectedItem)-1;
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+
         }
 
     }

src/Banker/Banker/bin/Debug/Banker.exe

Binary file modified.

src/Banker/Banker/bin/Debug/Banker.pdb

Binary file modified.

src/Banker/Banker/obj/x86/Debug/Banker.csproj.FileListAbsolute.txt

 C:\Users\Alex\Desktop\banker\Banker\obj\x86\Debug\Banker.pdb
 C:\Users\Alex\Desktop\banker\Banker\obj\x86\Debug\Banker.Form2.resources
 C:\Users\Alex\Desktop\banker\Banker\bin\Debug\Banker.exe.config
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\bin\Debug\Banker.exe.config
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\Banker.exe
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\Banker.pdb
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\bin\Debug\Banker.exe
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\bin\Debug\Banker.pdb
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\ResolveAssemblyReference.cache
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\Banker.Form1.resources
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\Banker.Form2.resources
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\Banker.Properties.Resources.resources
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
+C:\Users\Alex\Desktop\banker\src\Banker\Banker\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog

src/Banker/Banker/obj/x86/Debug/Banker.exe

Binary file modified.

src/Banker/Banker/obj/x86/Debug/Banker.pdb

Binary file modified.

src/Banker/Banker/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Binary file modified.

src/Banker/Banker/obj/x86/Debug/GenerateResource-ResGen.read.1.tlog

Binary file modified.

src/Banker/Banker/obj/x86/Debug/GenerateResource-ResGen.write.1.tlog

Binary file modified.