Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.  
  9. class OperaceM
  10. {
  11. public static double součet(double a, double b)
  12. {
  13. return a + b;
  14.  
  15. }
  16.  
  17. public static void soucin(double a, double b)
  18. {
  19. Console.WriteLine(a + b);
  20. }
  21.  
  22.  
  23. public double Součet2(double a, double b, double c)
  24. {
  25. return a + b + c;
  26. }
  27.  
  28.  
  29. }
  30.  
  31. class Ckalkulacka
  32. {
  33. double a, b;
  34.  
  35. public void nacteni()
  36. {
  37. Console.WriteLine("Prvni čislo");
  38. a = double.Parse(Console.ReadLine());
  39. Console.WriteLine("Druhe čislo");
  40. b = double.Parse(Console.ReadLine());
  41. }
  42.  
  43. public double součet()
  44. {
  45. return a + b;
  46. }
  47.  
  48. public double soucin()
  49. {
  50. return a * b;
  51. }
  52.  
  53. }
  54.  
  55. class Scitani1
  56. {
  57.  
  58. public int secti(int a, int b)
  59. {
  60. return a + b;
  61. }
  62.  
  63. public int secti(int a, int b, int c)
  64. {
  65. return a + b + c;
  66. }
  67.  
  68. public int secti(string a, string b)
  69. {
  70. return a.Length + b.Length;
  71. }
  72.  
  73.  
  74. //public int Secti(int a, int b)
  75. // {return a + b;}
  76. //public int Secti(int a, int b, int c)
  77. //{return Secti (Secti (a,b),c);}
  78. //public int Secti(int a, int b, int c, int d)
  79. //{return Secti(Secti(a,b,c),d);}
  80.  
  81. }
  82.  
  83.  
  84.  
  85. class CPocetZnaku
  86. {
  87.  
  88. public int pocetznaku(double a)
  89.  
  90. {
  91. return Convert.ToString(a).Length;
  92. }
  93.  
  94.  
  95.  
  96. public int pocetznaku(string a)
  97. {
  98. return a.Length;
  99. }
  100.  
  101. }
  102.  
  103.  
  104.  
  105. // Vytvořte třídu Hodnoty.
  106.  
  107. // Vytvořte neveřejné proměnné instance třídy a,b,c.
  108.  
  109. // Vytvořte přetíženou metodu instance třídy - Nacteni. Metoda pomocí parametrů načte 1 až tři hodnoty.
  110. // Metoda zajistí aby byly načtené jen kladné hodnoty. Pokud zadáme nekladnou hodnotu, pak to oznámí.
  111.  
  112. //Vytvořte metodu instance třídy- Soucet, která vrátí součet hodnot a,b,c.
  113.  
  114. //Vytvořte metodu instance třídy- Prumer, která vrátí prúměr kladných hodnoty a,b,c.
  115.  
  116. //V mainu načtěte hodnoty a zjistěte součet a průměr.
  117.  
  118.  
  119.  
  120. class CPretizeni
  121. {
  122. double a, b, c;
  123.  
  124. public void Nacteni(int a)
  125. {
  126.  
  127. if (a < 0)
  128. Console.WriteLine("Chyba, všechna čísla musí být kladná");
  129. else
  130. {
  131. this.a = a;
  132. }
  133. }
  134. public void Nacteni(int a, int b)
  135. {
  136. if (a < 0 || b < 0)
  137. Console.WriteLine("Chyba, všechna čísla musí být kladná");
  138. else
  139. {
  140. this.a = a;
  141. this.b = b;
  142.  
  143. }
  144.  
  145.  
  146. }
  147. public void Nacteni(int a, int b, int c)
  148. {
  149. if (a < 0 || b < 0 || c < 0)
  150. Console.WriteLine("Chyba, všechna čísla musí být kladná");
  151. else
  152. {
  153. this.a = a;
  154. this.b = b;
  155. this.c = c;
  156.  
  157. }
  158. }
  159. public double soucet()
  160. {
  161.  
  162.  
  163. return a + b + c;
  164.  
  165.  
  166.  
  167. }
  168.  
  169.  
  170. public double prumer()
  171. {
  172.  
  173. return (a+b+c)/3;
  174.  
  175. }
  176.  
  177.  
  178. }
  179.  
  180.  
  181.  
  182. class zboziC
  183. {
  184. double pocet = 0;
  185. string nazev = "";
  186. static double celk_kusy = 0;
  187.  
  188.  
  189. public zboziC()
  190. {
  191. nazev = "";
  192. pocet = 0;
  193. }
  194.  
  195.  
  196.  
  197.  
  198. public zboziC(double pocet, string nazev)
  199. {
  200. this.pocet = pocet;
  201. this.nazev = nazev;
  202. celk_kusy = celk_kusy + this.pocet;
  203. }
  204.  
  205.  
  206. public void pridavani_odebirani()
  207. {
  208. Console.WriteLine("Pridat = 1, odebrat = 2");
  209. double volba = double.Parse(Console.ReadLine());
  210. if (volba == 1)
  211. {}
  212.  
  213. else if(volba == 2)
  214. {}
  215. }
  216.  
  217. public void pridavani_odebirani(string nazev, double pocet)
  218. {
  219. Console.WriteLine("Pridat = 1, odebrat = 2");
  220. double volba = double.Parse(Console.ReadLine());
  221. if (volba == 1)
  222. {
  223. this.nazev = nazev;
  224. this.pocet = pocet;
  225. celk_kusy = celk_kusy + 1;
  226. }
  227. else if (volba == 2)
  228. {
  229. if (this.nazev == nazev)
  230. nazev = "";
  231. else if (this.pocet == pocet)
  232. pocet = 0;
  233. }
  234. }
  235. public static double vypis()
  236. {
  237. return celk_kusy;
  238. }
  239. public double vypis(string nazev)
  240. {
  241. return this.pocet;
  242. }
  243. }
  244.  
  245.  
  246.  
  247. public class priklad_2
  248. {
  249. public int cel_cislo ;
  250. public double cislo ;
  251. public string retezec ;
  252.  
  253.  
  254. public priklad_2(int cislo)
  255. {
  256. this.cislo = cel_cislo;
  257. }
  258. public priklad_2(double cislo)
  259. {
  260. this.cislo = cislo;
  261. }
  262. public priklad_2(string text)
  263. {
  264. text = retezec;
  265. }
  266. public priklad_2()
  267. {
  268. }
  269. public priklad_2(string text, double cislo, int cislo2)
  270. {
  271. text = retezec;
  272. this.cislo = cislo;
  273. cislo2 = cel_cislo;
  274. }
  275.  
  276.  
  277.  
  278. public static int vynasobeni(int a, int b)
  279. {
  280. return a * b;
  281. }
  282.  
  283.  
  284. //public void prirazeni(string jmeno,double cislo, int cislo2)
  285. //{
  286.  
  287. //}
  288. //public void prirazeni(string jmeno, double cislo, int cislo2)
  289. //{
  290.  
  291. //}
  292. //public void prirazeni(string jmeno, double cislo, int cislo2)
  293. //{
  294.  
  295. //}
  296.  
  297.  
  298.  
  299. }
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement