0% found this document useful (0 votes)
21 views2 pages

Test

Uploaded by

Thiên Quốc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Test

Uploaded by

Thiên Quốc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HinhCau_KeThuaHinhTron
{
class HinhChuNhat
{
protected int a, int b, int h; //khai bao canh HCN
// Xay dung phuong thuc khoi tao khong tham so
public HinhChuNhat()
{
a = 1;
b = 2;
}
// Xay dung phuong thuc khoi tao co tham so
public HinhChuNhat(int x, int y)
{
a = x;
b = y;
}
// Xay dung phuong thuc nhap
public void Nhap()
{
Console.Write("Nhap canh a:");
a = int.Parse(Console.ReadLine());
Console.Write("Nhap canh b:");
b = int.Parse(Console.ReadLine());
Console.Write("Nhap canh b:");
h = int.Parse(Console.ReadLine());
}
// Xay dung phuong thuc Tinh dien tich
public int DienTich()
{
return a * b;
}
// Xay dung phuong thuc Tinh chu vi
public int ChuVi()
{
return (a + b) x 2;
}
public void HienThi()
{
Console.Write("Dien tich HCN la:" + DienTich());
}
}
// Xay dung lop Ke thua
class HinhHopChuNhat : HinhChuNhat
{
// phuong thuc Tinh the tich
public int TinhTheTich()
{
return base.DienTich() * h;
}
// phuong thuc Tinh dien tich toan phan
public int TinhDTtoanphan()
{
return base.2h*DienTich()+ 2*DienTich();
}
// Tinh The Tich
public void HienThiTheTich()
{
Console.Write("The tich Hinh Lap Phuong la:" + TinhTheTich());
}
// Tinh The dien tich toan phan
public void HienThiDTToanPhan()
{
Console.Write("Dien tich toan phan Hinh Lap Phuong la:" +
TinhDTtoanphan());
}
}
// CTC
class Program
{
static void Main(string[] args)
{
HinhHopChuNhat HHCN = new HinhHopChuNhat();
HHCN.Nhap();
HHCN.HienThi();
Console.WriteLine();
HHCN.HienThiTheTich();
Console.WriteLine();
HHCN.HienThiDTToanPhan();
Console.ReadKey();

}
}
}

You might also like