10:37 

;>

n0n4m3r
Anima Libera

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;

namespace forTests
{
class Student
{
private string sName;
private string course;
private bool income;
public Student()
{
sName = "";
course = "";
income = false;
}
public Student(string n, string c, bool i)
{
this.sName = n;
this.course = c;
this.income = i;
}
}
class Auto
{
private int runned;
protected int year;
internal string mark;
public string developer;
}

class Television
{
private static int maxChannel = 99;
private static int minChannel = 0;
public static int curChannel;
private int _volume = 50;

public int Volume
{
get { return _volume; }
set { _volume = value; }
}



public static void changeChannel(ConsoleKeyInfo k)
{
if (k.Key == ConsoleKey.UpArrow && curChannel < maxChannel)
{
Console.Clear();
curChannel++;
Console.WriteLine("Current channel: " + curChannel);
}
else if (k.Key == ConsoleKey.UpArrow && curChannel >= maxChannel)
{
Console.Clear();
curChannel = minChannel;
Console.WriteLine("Current channel: " + curChannel);
}
else if (k.Key == ConsoleKey.DownArrow && curChannel > minChannel)
{
Console.Clear();
curChannel--;
Console.WriteLine("Current channel: " + curChannel);
}
else if (k.Key == ConsoleKey.DownArrow && curChannel <= minChannel)
{
Console.Clear();
curChannel = maxChannel;
Console.WriteLine("Current channel: " + curChannel);
}
else if (k.Key == ConsoleKey.Spacebar)
{
do
{
Console.Clear();
Console.WriteLine("Choose channel: ");
curChannel = Convert.ToInt32(Console.ReadLine());
} while (curChannel < minChannel | curChannel > maxChannel);
Console.WriteLine("Current channel: " + curChannel);
}

}
}
class Program
{
public static int[] modChange(int[] array, int toChange)
{
for (int i = 0; i < array.Length; ++i)
{
if (array[i] == toChange)
array[i] = array[i] * (-1);
}
return array;
}

public static void lower(int[] hello)
{
int lowest = hello[0];
for (int i = 1; i < hello.Length; ++i)
{
if (hello[i] < lowest)
lowest = hello[i];
}
Console.Write(lowest);
}
public static void febbernachi(int number)
{
int num1 = 1, num2 = 1;
if (number <= 2)
Console.WriteLine("Element number " + number + " is 1");
else
{
for (int i = 2; i != number; ++i)
{
if (num1 > num2)
num2 += num1;
else
num1 += num2;
}
Console.WriteLine("Element number " + number + " is " + (num1 > num2 ? num1 : num2));
}

}

static void Main(string[] args)
{
/* int num = 1;
for (int i = 1; i <= 20; ++i)
{
Console.WriteLine(num);
num += 3;
}

string password="";
while (password != "root")
{
Console.Write("Enter password: ");
password = Console.ReadLine();
}

Random arrayTo = new Random();
int[] array1 = new int[10];
int[] array2 = new int[10];
int[] array3 = new int[10];

for (int i = 0; i < 10; ++i)
{
array1[i] = arrayTo.Next(1, 11);
array2[i] = arrayTo.Next(1, 11);
array3[i] = array1[i] + array2[i];
Console.WriteLine("First number is " + array1[i] + "; second is " + array2[i] + ". Summ is: " + array3[i]);
}

Console.ReadKey();
*/


/* int[] array = new int[100];
Random filling = new Random();
for (int i = 0; i < array.Length; ++i)
{
array[i] = filling.Next(1, 101);
Console.Write(array[i] + "; ");
}


foreach (int between in array)
if (between > 20 && between < 50)
Console.WriteLine(between);
Console.ReadKey();
*/
/*int[] array = new int[100];
Random filling = new Random();
for (int i = 0; i < array.Length; ++i)
{
array[i] = filling.Next(-10, 11);
Console.Write(array[i] + " ");
}
Console.Write("\n\n");
modChange(array, -3);

for (int i = 0; i < array.Length; ++i)
Console.Write(array[i] + " ");
Console.Write("\n\n");

int[] three = new int[3];
for (int i = 0; i < three.Length; ++i)
{
three[i] = filling.Next(-10, 11);
Console.Write(three[i] + " ");
}
lower(three);

Console.Write("\n\n");

Console.Write("Enter number: ");
int counter = Convert.ToInt32(Console.ReadLine());
febbernachi(counter);*/

/*
//Task1
string s="Nikolay makes me laught!";
Console.WriteLine(s);
Console.WriteLine(s.Replace("Nikolay", "Oleg"));
//Task2
s = "Сегодня мы с вами рассмотрели, как работать со строками в Си-шарп." +
"Были описаны основные операторы и методы, которые используются для работы со строками";
string need = "Были описаны основные операторы и методы";
s = s.Remove(0, s.IndexOf("Б"));
s = s.Remove(need.Length);
Console.WriteLine(s);
//Task3
s = "Login1,LOgin2,login3,loGin4";
s = s.ToLower();
string[] logins = s.Split(',');
for (int i = 0; i < logins.Length; ++i)
Console.WriteLine(logins[i]);
*/


/*
Random filling = new Random();
int[] array = new int[10];
for (int i = 0; i < array.Length; ++i)
array[i] = filling.Next(0, 11);
for (; ; )
{
try
{
for (int i = 0; i < array.Length; ++i)
Console.Write(array[i] + " ");
Console.WriteLine("\nEnter numbers from 1 to 10: ");
int num1, num2;
num1 = Convert.ToInt32(Console.ReadLine());
num2 = Convert.ToInt32(Console.ReadLine());
int result = array[num1 - 1] + array[num2 - 1];
Console.WriteLine(result);
break;
}
catch (FormatException ex)
{
Console.Clear();
Console.WriteLine("Need to enter numbers only!");
}
catch (IndexOutOfRangeException ex)
{
Console.Clear();
Console.WriteLine("Please enter numbers from 1 to 10 only!");
}
}
*/


/*
StreamWriter write = new StreamWriter("S:\\test.txt");
for (int i = 0; i < 500; ++i)
write.Write((i+1) + " ");
write.WriteLine();
string[] colors = { "red", "green", "blue", "black", "white" };
for (int i = 0; i < colors.Length; ++i)
{
write.WriteLine(colors[i]);
}
write.Close();
StreamReader read = new StreamReader("S:\\test2.txt");
int lenght = 0;
string line = "", longestLine = "";
if (!read.EndOfStream)
{
line = read.ReadLine();
if (line.Length > lenght)
{
lenght = line.Length;
longestLine = line;
}
}
Console.WriteLine("Longest line is: " + longestLine + "\nSize of line is: " + lenght);
read.Close();

Console.ReadKey();
*/


/*
Auto bmw = new Auto();
//bmw.runned = 500;
//bmw.year = 1999;
bmw.mark = "X3";
bmw.developer = "Germany";

Console.WriteLine(bmw.mark + ", " + bmw.developer);
Console.ReadKey();
* */

ConsoleKeyInfo pressed;
Television myTV = new Television();
Television.curChannel = 10;
do
{
Console.WriteLine("Press up or down to change channels or space to choose specific channel: ");
pressed = Console.ReadKey();
if (pressed.Key == ConsoleKey.LeftArrow && myTV.Volume > 0)
{
Console.Clear();
myTV.Volume--;
Console.WriteLine("Volume is: " + myTV.Volume);
}
else if (pressed.Key == ConsoleKey.RightArrow && myTV.Volume < 100)
{
Console.Clear();
myTV.Volume++;
Console.WriteLine("Volume is: " + myTV.Volume);
}
else
Television.changeChannel(pressed);
//Console.WriteLine(pressed.Key);

} while (pressed.Key != ConsoleKey.Escape);

}
}
}

@темы: extended

URL
   

Heaven

главная