public static void Main() { Punkt a = new Punkt(); Console.WriteLine("{0}\t{1}", a.x, a.y); a.x = -3; a.y = 1; Console.WriteLine("{0}\t{1}", a.x, a.y); Console.ReadKey(); }
public static void Main() { Punkt p = new Punkt(); p.UstawX(100); p.UstawY(200); Console.WriteLine("x = " + p.PobierzX()); Console.WriteLine("y = " + p.PobierzY()); Console.ReadKey(); }
// tworzenie miejsca na rysowanie private void Form1_Load(object sender, EventArgs e) { var srodek = new Punkt((ClientSize.Width + 200) / 2, ClientSize.Height / 2, Color.Red, this); // okresla srodek form1 for (int i = 0; i < 10; i++) { figura[i] = srodek; } siatka = srodek; }
static void Main(string[] args) { Punkt punkt1 = new Punkt(10, 20); Console.WriteLine("punkt 1 x wynosi: {0}", punkt1.x); Console.WriteLine("punkt 1 y wynosi: {0}", punkt1.y); Console.ReadKey(); // na kolosie funkcje }
Punkt UstawXY(Punkt p) { Punkt q = new Punkt(); q.x = x; q.y = y; x = p.x; y = p.y; return(q); }
public static void Main() { Punkt p = new Punkt(); Punkt3D q = new Punkt3D(); p.UstawXY(3, 4); q.UstawXYZ(3, 4, 5); Console.WriteLine(p.odleglosc()); Console.WriteLine(q.odleglosc()); Console.ReadKey(); }
public static void Main() { Punkt p = new Punkt(); Punkt3D q = new Punkt3D(); p.UstawXY(3, 4); q.UstawXYZ(3, 4, 5); p.WyswietlWspolrzedne(); q.WyswietlWspolrzedne(); Console.ReadKey(); }
private static void SprawdzTrafienie(Punkt znaleziony) { if (znaleziony == null) { Console.WriteLine("Nie trafiono"); } else { Console.WriteLine("Trafienie!"); } }
public static void Main() { Punkt p = new Punkt(); p.UstawR(5.0); p.UstawSinusalfa(0.8); Console.WriteLine("r = " + p.PobierzR()); Console.WriteLine("sina = " + p.PobierzSinusalfa()); p.WyswietlWspolrzedne(); Console.ReadKey(); }
// Findet den Punkt mit dem angenähert minimalen Abstand zu allen Elementen // auf dem Spielfeld und dem Spielfeldrand. private Punkt findePunkt() { int index = 0; int anzahl = 4; anzahl += SugarHills.Count; anzahl += Fruits.Count; anzahl += AntHills.Count; punkte = new Punkt[anzahl]; foreach (CoreSugar zucker in SugarHills) { punkte[index++] = new Punkt(zucker.CoordinateBase); } foreach (CoreFruit obst in Fruits) { punkte[index++] = new Punkt(obst.CoordinateBase); } foreach (CoreAnthill bau in AntHills) { punkte[index++] = new Punkt(bau.CoordinateBase); } int x, y, a; int maximum = 0; int dx = Width / 100; int dy = Height / 100; int nx = 0; int ny = 0; // Die optimale Koordinate schätzen. for (x = 0; x < Width; x += dx) { for (y = 0; y < Height; y += dy) { a = minimum(x, y); if (a > maximum) { maximum = a; nx = x; ny = y; } } } // Noch ein wenig von der optimalen Koordiante abweichen. double radius = mapRandom.Next(0, (int)(Math.Sqrt(maximum) / 3d)); double winkel = mapRandom.Next(0, 359); nx += (int)(radius * Math.Cos(winkel * Math.PI / 180d)); ny += (int)(radius * Math.Sin(winkel * Math.PI / 180d)); return(new Punkt(nx, ny, 0)); }
public void obliczGranice(int i, int j, int k) { //WYLICZANIE WSZYSTKICH WIERZCHOŁKÓW KOSTKI: granice[0] = new Punkt(i, j, k); granice[1] = new Punkt(i + 1, j, k); granice[2] = new Punkt(i + 1, j + 1, k); granice[3] = new Punkt(i, j + 1, k); granice[4] = new Punkt(i, j, k + 1); granice[5] = new Punkt(i + 1, j, k + 1); granice[6] = new Punkt(i + 1, j + 1, k + 1); granice[7] = new Punkt(i, j + 1, k + 1); }
public static void Main() { Punkt a = new Punkt(); Console.WriteLine("{0} {1}", a.x, a.y); a.x = 3; Console.WriteLine("{0} {1}", a.x, a.y); Punkt3D b = new Punkt3D(); Console.WriteLine("{0} {1} {2}", b.x, b.y, b.z); Console.ReadKey(); }
public static void Main() { Punkt p1 = new Punkt(5, 7); Punkt3D p2 = new Punkt3D(1, 2, 3); Console.WriteLine(p1 + "\n"); Console.WriteLine(p2 + "\n"); Punkt p3 = (Punkt)p2; Console.WriteLine(p2 + "\n"); Console.WriteLine(p3); Console.ReadKey(); }
static void Main(string[] args) { Punkt punktA = new Punkt(); punktA.x = 0; punktA.y = 0; Console.WriteLine(punktA.dodaj(2, 3)); Console.WriteLine(punktA.x + "," + punktA.y); Console.WriteLine("Hello World!"); }
private void PrzesunNeuron(Punkt pTr, Punkt p, double odl) { if (FunkcjaZmian(odl) == 0) { return; } double x = pTr.x - p.x; double y = pTr.y - p.y; // Przesuniecie p.x += FunkcjaSilyPrzesuniecia(odl) * x; p.y += FunkcjaSilyPrzesuniecia(odl) * y; }
public static void Main() { Punkt p = new Punkt(); try { Punkt3D punkt3D = (Punkt3D)p; punkt3D.z = 10; } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.ReadKey(); }
static void Main(string[] args) { PunktKolorowy b = new PunktKolorowy("czerwony", 1, 2); PunktKolorowy c = new PunktKolorowy("niebieski"); Punkt r = new Punkt(); Punkt p = new Punkt(1, 4); p.Wyswietl(); Console.WriteLine(p.Odleglosc(r)); b.Wyswietl(); c.Wyswietl(); Console.WriteLine(b.Odleglosc(r)); Console.WriteLine(c.Odleglosc(r)); Console.ReadKey(); }
static void Main2() { Punkt a = new Punkt(1, 2); Punkt b = new Punkt(3, 4); Odcinek o = new Odcinek(a, b); Console.WriteLine(o); Console.WriteLine(o.DlugoscJakoFunkcja()); Console.WriteLine(o.Dlugosc); Odcinek o1 = new Odcinek(b, a); Console.WriteLine(o == o1); // false Console.WriteLine(o.Equals(o1)); // true, bo zdefiniowane Equals }
public Punkt SzukajPierwszegoNajblizszego(Punkt zadany, double promien) { while (true) { Punkt punkt = WczytajPunkt(); if (KoniecSprawdzania(punkt)) { return(null); } if (SprawdzTrafienie(punkt, zadany, promien)) { return(punkt); } } }
//----------RYSOWANIE----------// public void nowyPanel1_Paint(object sender, PaintEventArgs e) { //PODSTAWOWE DEKLARACJE: Graphics g = e.Graphics; Punkt obserwator = Punkt.RFiTetaToXYZ(r, fi, teta); T3d projektor = new T3d(obserwator, nowyPanel1.ClientRectangle); if (wyswietlanie == 0) { indeksy(projektor, obserwator, g); } else { sorty(projektor, obserwator, g); } }
static void Main(string[] args) { Punkt punkt1 = new Punkt(); Punkt punkt2; punkt1.x = 100; punkt1.y = 200; Console.WriteLine("Punkt x wynosi: {0}", punkt1.x); Console.WriteLine("Punkt y wynosi: {0}", punkt1.y); Console.ReadKey(); }
static void Main() { Console.WriteLine("Biathlon"); Punkt zadany = WczytajPunktPoczatkowy(); double promien = 3.0; // Kompozycja obiektów z użyciem wstrzykiwania zależności (Dependency Injection) IMiaraOdleglosci miara = new MetrykaEuklidesowa(); OdlegloscPunktow odleglosc = new OdlegloscPunktow(miara); Strzelnica st = new Strzelnica(odleglosc); Punkt znaleziony = st.SzukajPierwszegoNajblizszego(zadany, promien); SprawdzTrafienie(znaleziony); Console.ReadLine(); }
static void Main(string[] args) { // struktura Punkt punkt = new Punkt(3, 10); Indeksator indeksator = new Indeksator(); indeksator[1] = 5; Wyliczenia wyliczenia = new Wyliczenia(); Console.WriteLine(wyliczenia.PobierzDzienTygodniaJakoLiczbe()); Console.WriteLine(wyliczenia.PobierzNazweDniaTygodnia()); ZmienneStatyczne zmienne = new ZmienneStatyczne(10, 150); zmienne.UstawWiek(18); ZmienneStatyczne.dolnyLimit = 15; ZmienneStatyczne.gornyLimit = 20; Console.ReadKey(); }
static void Main(string[] args) { Punkt punkt1 = new Punkt(); punkt1.x = 5; punkt1.y = 15; Punkt punkt2; //Punkt punkt2 = new Punkt(); Console.WriteLine("Punkt 1: x = {0}, y = {1}", punkt1.x, punkt1.y); Console.WriteLine("Punkt 2: x = {0}, y = {1}", punkt2.x, punkt2.y); Console.ReadKey(); }
static void Main(string[] args) { Punkt p1 = new Punkt(); // składowe=pola struct zaincjowane wart. domyślnymi //Punkt p1; // j.w ale składowe struct niezainicjowane p1.X = 0x17; Punkt p2 = p1; // przypisanie powoduje utworzenie kopii WriteLine(p1.X); WriteLine(p2.X); //??? p1.X = 0x23; //zmiana wartości p1.X NIE wpływa na p2.X WriteLine(p1.X); WriteLine(p2.X); WriteLine(p1.Y); //??? WriteLine(p2.Y); //??? }
Kwadrat(Punkt D, Punkt B) { this.D = D; this.B = B; if (D.x >= 0 && B.x >= 0) { this.bok = B.x - D.x; } if (D.x < 0 && B.x >= 0) { this.bok = abs(D.x) + B.x; } if (D.x < 0 && B.x < 0) { this.bok = abs(D.x) - abs(B.x); } }
private void button9_Click(object sender, EventArgs e) { double iloscPtk = 4; double licznik = (Double.Parse(numericUpDown4.Text)); double mianownik = (Double.Parse(numericUpDown4.Text)) + 1; int iloscKwadratow = (int)(Double.Parse(numericUpDown3.Text)); Punkt[] tablica = new Punkt[(int)iloscPtk]; double przyrost = 2 * Math.PI / iloscPtk; double alfa = 0.0 + 2 * Math.PI / 8; double r = 50; Punkt backup = center; center.x -= 150; center.y -= 150; for (int f = 0; f < 5; f++) { for (int z = 0; z < 5; z++) { for (int i = 0; i < iloscPtk; i++) { alfa += przyrost; tablica[i] = new Punkt((float)(r * Math.Cos(alfa)), (float)(r * Math.Sin(alfa))) + center; } for (int j = 0; j < iloscKwadratow; j++) { for (int i = 0; i < iloscPtk; i++) { g.DrawLine(pen1, (float)tablica[i].x, (float)tablica[i].y, (float)tablica[(i + 1) % (int)iloscPtk].x, (float)tablica[(i + 1) % (int)iloscPtk].y); } for (int k = 0; k < 4; k++) { tablica[k] = new Punkt((((licznik * tablica[k].x) + (tablica[(k + 1) % (int)iloscPtk].x))) / mianownik, (((licznik * tablica[k].y) + (tablica[(k + 1) % (int)iloscPtk].y))) / mianownik); } } center.x += 73; } center.x -= 73 * 5; center.y += 73; } }
static void Właściwości() { /* Załóżmy, że chcemy zaimplementować klase 'Punkt', który bedzie przyjmował wartości tylko z jakiegoś określonego przedziału. Dla X max zakres to 1920 dla Y 1080. * 'Punkt' to struktura i zawiera 2 właściwości. */ Punkt punkt = new Punkt(); punkt.X = 1209; // używamy akcesora 'set', wartość 1209 zostanie przekazana do ukrytego parametru 'value'. punkt.Y = 150; int x = punkt.X; // używamy akcesora 'get' punkt.Y += 12; // używamy akcesora 'get' i 'set' punkt.X = 99999; // zostanie zgłoszony wyjątek ArgumentException z metodzy akcesora 'set'. }
public void KraftwerkTask() { generator.MaschineAntreiben(Y); Generator_n = generator.Drehzahl(); Generator_U = generator.Spannung(S7Analog.S7_Analog_2_Double(Gen_Ie, 10)); Generator_f = generator.Frequenz(); Netz_Winkel = DrehstromZeiger.WinkelBerechnen(Zeitdauer, Frequenz, Netz_Winkel); Generator_Winkel = DrehstromZeiger.WinkelBerechnen(Zeitdauer, Generator_f, Generator_Winkel); Netz_Momentanspannung = DrehstromZeiger.GetSpannung(Netz_Winkel, Spannung); Generator_Momentanspannung = DrehstromZeiger.GetSpannung(Generator_Winkel, Generator_U); FrequenzDifferenz = Frequenz - Generator_f; Zeiger SpannungsDiff = new Zeiger(Generator_Momentanspannung, Netz_Momentanspannung); SpannungsUnterschiedSynchronisieren = SpannungsDiff.Laenge(); }
static void DekonstrukcjaObiektu() { /* Klasa Punkt * Konstruktor inicjalizuje obiekt a Dekonstruktor służy do zbadania obiektu i wydobycia wartości wszystkich pól instancji. * Musi się nazywać 'Deconstruct' nie zwracać wartości 'void' i przyjmować przynajniej jeden outowy parametr. np. * public void Deconstruct(out int x, out int y){ x = this.x; y = this.y; } */ Punkt p = new Punkt(1, 2); p.Deconstruct(out int a, out int b); (int x, int y) = p; /* Wywoływanie Doconstructora. * Można także użyć ktorki. Kompilator automatycznie użyje metody Deconstruct zdefinowanej w klasie Point. * Nalezy pamietac żeby zainstalowac nuget System.ValueType. Więcej na temat krotki w roz. 3. */ }
static void DemoWart() { Punkt p1 = new Punkt(); p1.X = 0x17; Punkt p2 = p1; //przypisanie powoduje utworzenie kopii WriteLine(p1.X); WriteLine(p2.X); //??? p1.X = 0x23; //zmiana wartości p1.X NIE wpływa na p2.X WriteLine(p1.X); WriteLine(p2.X); WriteLine(p1.Y); //zainicjowane domyślnie wart. 0 WriteLine(p2.Y); //zainicjowane domyślnie wart. 0 }