Umirov Rahimjonning o’quv-amaliyoti davomida tayyorlagan. Hisobotlari Amaliyot rahbari: O. Primqulov Bajardi: R. Umirov 1-kun
Download 484.63 Kb.
|
Rahimjon Hisobot
- Bu sahifa navigatsiya:
- 23-Mavzu. Voris sinflarini yaratish va ulardan foydalanish.
partial class Klass{ public void Metod3(){ Metod(); } } class program{ static void Main(){ Klass ob=new Klass(1,16); ob.Metod3(); } } } 11-Masala namespace Rahimjon{ partial class Klass{ private const double PI=3.14; private double d; private double t; private double v; public Klass(double v,double t,double d){ this.v=v; this.t=t; this.d=d; } partial void Metod(); } partial class Klass{ public double Metod1(){ double N=(v*t)/(PI*d); return N; } partial void Metod(){ Console.WriteLine(Metod1()); } } partial class Klass{ public void Metod2(){ Metod(); } } class program{ static void Main(){ Klass ob=new Klass(7,600,0.7); ob.Metod2(); } } } 23-Mavzu. Voris sinflarini yaratish va ulardan foydalanish. Asosiy sinf (base class) - bu dastur kodi ishlatiladigan sinf meros (lotin) sinflari. Lotin klassi (derived class) – bu sinf asosiy sinfning dasturiy kodidan foydalanadi va uning ehtiyojlari uchun uni o'zgartiradi (kengaytiradi). Boshqa dasturlash tillarida (masalan, Java) asosiy sinf ham deyiladi Superclass( superclass) va lotin klassi subclass deb ataladi. Ikki sinf uchun merosning sintaksisi. Umumiy shakl Agar bitta sinf boshqa asosiy sinfni egallasa, unda e'lonning umumiy shakli ushbu sinf quyidagicha: class derived_class : base_class { // sinf tanasi // ... } qaerda derived_class-lotin sinfining nomi; base_class-asosiy sinf nomi. Misol uchun. // asosiy sinf class Base { // maydonlar, sinf usullari // ... } // sinf, meros qilib olingan Yuqoridagi misolda Base-asosiy sinf, Derived-sinf Base sinfining imkoniyatlarini meros qilib oladi. Sinfda DASTURI: 7-Masala using System; namespace Rahimjon{ class Klass1{ protected int min; protected int hours; public Klass1(int min,int hours) { this.min=min; this.hours=hours; } } class Klass2:Klass1{ private int min1; public Klass2(int min,int hours,int min1):base(min,hours) { this.min1=min1; } public double Metod(){ double n=min*hours/min1; return n; } } class program{ static void Main(){ Console.Write(" Hours : "); int x=int.Parse(Console.ReadLine()); Console.Write(" Minut : "); int y=int.Parse(Console.ReadLine()); Console.Write(" intermediate time :" ); int z=int.Parse(Console.ReadLine()); Klass1 ob1=new Klass1(x,y); Klass2 ob2=new Klass2(x,y,z); Console.WriteLine(" number of operations: "+ob2.Metod()); } } } 11-Masala using System; namespace Rahimjon{ class Klass1{ protected int a1,b1; public Klass1(int a1,int b1){ this.a1=a1; this.b1=b1;} } class Klass2:Klass1{ private int i=-1; public Klass2(int a1,int b1):base(a1,b1){} public double Metod1(){ double z1=a1+b1*i; return z1; } public double Metod2(){ double z2=a1-b1*i; return z2; } public double Metod3(){ double p=Metod1()*Metod2(); return p; } } class program{ static void Main(){ Console.Write("действительная части числа : "); int x=int.Parse(Console.ReadLine()); Console.Write(" мнимая части числа : "); int y=int.Parse(Console.ReadLine()); Klass1 ob1=new Klass1(x,y); Klass2 ob2=new Klass2(x,y); Console.WriteLine(" z1: "+ob2.Metod1()); Console.WriteLine(" z2: "+ob2.Metod2()); Console.WriteLine(" произведение двух комплексных чисел. : "+ob2.Metod3()); }} } Download 484.63 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling