Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class OperaceM
- {
- public static double součet(double a, double b)
- {
- return a + b;
- }
- public static void soucin(double a, double b)
- {
- Console.WriteLine(a + b);
- }
- public double Součet2(double a, double b, double c)
- {
- return a + b + c;
- }
- }
- class Ckalkulacka
- {
- double a, b;
- public void nacteni()
- {
- Console.WriteLine("Prvni čislo");
- a = double.Parse(Console.ReadLine());
- Console.WriteLine("Druhe čislo");
- b = double.Parse(Console.ReadLine());
- }
- public double součet()
- {
- return a + b;
- }
- public double soucin()
- {
- return a * b;
- }
- }
- class Scitani1
- {
- public int secti(int a, int b)
- {
- return a + b;
- }
- public int secti(int a, int b, int c)
- {
- return a + b + c;
- }
- public int secti(string a, string b)
- {
- return a.Length + b.Length;
- }
- //public int Secti(int a, int b)
- // {return a + b;}
- //public int Secti(int a, int b, int c)
- //{return Secti (Secti (a,b),c);}
- //public int Secti(int a, int b, int c, int d)
- //{return Secti(Secti(a,b,c),d);}
- }
- class CPocetZnaku
- {
- public int pocetznaku(double a)
- {
- return Convert.ToString(a).Length;
- }
- public int pocetznaku(string a)
- {
- return a.Length;
- }
- }
- // Vytvořte třídu Hodnoty.
- // Vytvořte neveřejné proměnné instance třídy a,b,c.
- // Vytvořte přetíženou metodu instance třídy - Nacteni. Metoda pomocí parametrů načte 1 až tři hodnoty.
- // Metoda zajistí aby byly načtené jen kladné hodnoty. Pokud zadáme nekladnou hodnotu, pak to oznámí.
- //Vytvořte metodu instance třídy- Soucet, která vrátí součet hodnot a,b,c.
- //Vytvořte metodu instance třídy- Prumer, která vrátí prúměr kladných hodnoty a,b,c.
- //V mainu načtěte hodnoty a zjistěte součet a průměr.
- class CPretizeni
- {
- double a, b, c;
- public void Nacteni(int a)
- {
- if (a < 0)
- Console.WriteLine("Chyba, všechna čísla musí být kladná");
- else
- {
- this.a = a;
- }
- }
- public void Nacteni(int a, int b)
- {
- if (a < 0 || b < 0)
- Console.WriteLine("Chyba, všechna čísla musí být kladná");
- else
- {
- this.a = a;
- this.b = b;
- }
- }
- public void Nacteni(int a, int b, int c)
- {
- if (a < 0 || b < 0 || c < 0)
- Console.WriteLine("Chyba, všechna čísla musí být kladná");
- else
- {
- this.a = a;
- this.b = b;
- this.c = c;
- }
- }
- public double soucet()
- {
- return a + b + c;
- }
- public double prumer()
- {
- return (a+b+c)/3;
- }
- }
- class zboziC
- {
- double pocet = 0;
- string nazev = "";
- static double celk_kusy = 0;
- public zboziC()
- {
- nazev = "";
- pocet = 0;
- }
- public zboziC(double pocet, string nazev)
- {
- this.pocet = pocet;
- this.nazev = nazev;
- celk_kusy = celk_kusy + this.pocet;
- }
- public void pridavani_odebirani()
- {
- Console.WriteLine("Pridat = 1, odebrat = 2");
- double volba = double.Parse(Console.ReadLine());
- if (volba == 1)
- {}
- else if(volba == 2)
- {}
- }
- public void pridavani_odebirani(string nazev, double pocet)
- {
- Console.WriteLine("Pridat = 1, odebrat = 2");
- double volba = double.Parse(Console.ReadLine());
- if (volba == 1)
- {
- this.nazev = nazev;
- this.pocet = pocet;
- celk_kusy = celk_kusy + 1;
- }
- else if (volba == 2)
- {
- if (this.nazev == nazev)
- nazev = "";
- else if (this.pocet == pocet)
- pocet = 0;
- }
- }
- public static double vypis()
- {
- return celk_kusy;
- }
- public double vypis(string nazev)
- {
- return this.pocet;
- }
- }
- public class priklad_2
- {
- public int cel_cislo ;
- public double cislo ;
- public string retezec ;
- public priklad_2(int cislo)
- {
- this.cislo = cel_cislo;
- }
- public priklad_2(double cislo)
- {
- this.cislo = cislo;
- }
- public priklad_2(string text)
- {
- text = retezec;
- }
- public priklad_2()
- {
- }
- public priklad_2(string text, double cislo, int cislo2)
- {
- text = retezec;
- this.cislo = cislo;
- cislo2 = cel_cislo;
- }
- public static int vynasobeni(int a, int b)
- {
- return a * b;
- }
- //public void prirazeni(string jmeno,double cislo, int cislo2)
- //{
- //}
- //public void prirazeni(string jmeno, double cislo, int cislo2)
- //{
- //}
- //public void prirazeni(string jmeno, double cislo, int cislo2)
- //{
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement