Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication6
- {
- class Test
- {
- static Random rnd = new Random();
- static int[] limints = { 51, 63, 75, 87, 101 };
- public Test()
- {
- neptun = setNeptun();
- result = rnd.Next(0, 101);
- }
- private string neptun;
- public string Neptun
- {
- get { return neptun; }
- set { neptun = value; }
- }
- private int result;
- public int Result
- {
- get { return result; }
- set { result = value; }
- }
- public Test(string neptun)
- {
- Neptun = neptun;
- Result = rnd.Next(0, 101);
- }
- string setNeptun()
- {
- string s = "";
- for (int i = 0; i < 6; i++)
- {
- if (rnd.Next(0, 2) == 0)
- {
- s += (char)rnd.Next(65, 91); //casting of a number to make it a character (65 is the ASCII code of A and 91 is the ASCII of Z)
- }
- else
- {
- s += rnd.Next(0, 10);
- }
- /* alternative:
- string s = "ABCDEFGHIJKLMNOPQRSTUWZ";
- string s1 = "";
- for ( int i = 0; i<6, i++)
- {
- s1 += s[rnd.Next(0, s.Length)];
- }*/
- }
- return s;
- }
- public bool succesful()
- {
- if (result < limints[0]) return false;
- return true;
- }
- public string print()
- {
- return neptun + " " + result + " ";
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int n = 10;
- Console.WriteLine("\nTask 1");
- Test[] testobject = new Test[n];
- for (int i = 0; i < n; i++)
- {
- testobject[i] = new Test();
- Console.WriteLine(testobject[i].print());
- }
- Console.WriteLine("\nTask 2");
- for (int i = 0; i < n; i++)
- {
- if (testobject[i].succesful()) Console.WriteLine(testobject[i].print());
- }
- Console.WriteLine("\nTask 3: ");
- testobject[1].Result = 99;
- testobject
- int best = testobject[0].Result;
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement