This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Product */ | |
class Pizza | |
{ | |
private string dough = ""; // тесто, корж | |
private string sauce = ""; // соус | |
private string topping = ""; // начинка | |
public void SetDough(string dough) | |
{ | |
this.dough = dough; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger | |
{ | |
private static Logger instance; // 1) приватная статическая ссылка на единственный экземпляр класса | |
private int logCount = 0; // сколько раз происходила запись строки в файл | |
private Logger() // 2) конструктор - приватный (запрещает создавать объекты за пределами класса) | |
{ | |
} | |
public static Logger GetInstance() // 3) публичный статический геттер на получение единственного объекта |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton | |
{ | |
private static Singleton instance; | |
private int value; | |
private Singleton() | |
{ | |
value = 50; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PegLeg // деревянная нога | |
{ | |
public string Color { get; set; } // brown will be OK | |
public bool Dirty { get; set; } // yes / no | |
public double Length { get; set; } // inches | |
public int Usability { get; set; } // 0 - 100% | |
public PegLeg() | |
{ | |
Console.WriteLine("Peg Leg C-TOR!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hat | |
{ | |
public string Color { get; set; } | |
public string Model { get; set; } | |
public double Price { get; set; } | |
public override string ToString() | |
{ | |
return Model; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Person | |
{ | |
public string Name { get; set; } // 1) наличие свойства с типом другого класса/структуры - это ассоциация | |
public string Surname { get; set; } | |
public string SaySomething() // 2) возврат объекта с типом другого класса/структуры - это тоже ассоциация | |
{ | |
string local; // 3) создание локальной переменной/константы с типом другого класса/структуры - это третий вариант ассоциации |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
[AttributeUsage(AttributeTargets.Property)] | |
public class MyAttribute : Attribute | |
{ | |
public string Description { get; } | |
public MyAttribute(string description) | |
{ | |
Description = description; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
#include <shlwapi.h> | |
using namespace std; | |
int main() | |
{ | |
setlocale(0, ""); | |
//////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://git.io/vDJXv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
class Tester | |
{ | |
public static void GetColor(short y, short x, uint length = 1) | |
{ | |
var colors = new ushort[1]; | |
uint numberOfCharactersRead; | |
if (ReadConsoleOutputAttribute(GetStdHandle(-11), colors, length, new Coord(x, y), out numberOfCharactersRead)) |