Skip to main content

Liên kết: Hình Chữ Nhật + Hình Hộp + Form1

// Hình Chữ Nhật

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

namespace WindowsFormsApp3
{
class HCN
{
public int cd;
public int cr;
public HCN(int cd,int cr)
{
this.cd = cd;
this.cr = cr;
}
public int tinhDT()
{
return cd * cr;
}
public int tinhCV()
{
return (cd + cr) * 2;
}
public String xuatTT()
{
return "dt: " + tinhDT() + " cv: " + tinhCV();

}
}
}



// Hình Hộp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp3
{
class HH : HCN
{
public int cc;
public HH(int cd,int cr,int cc):base(cd,cr)
{
this.cc = cc;
}
public int tinhTT()
{
return tinhDT() * cc;
}
public String xuatTT()
{
return base.xuatTT() + " tt: " + tinhTT();
}
}
}




// Form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked==true)
{
label3.Enabled = true;
textBox3.Enabled = true;
}
else
{
label3.Enabled = false;
textBox3.Enabled = false;
}
}

private void button1_Click(object sender, EventArgs e)
{
int cd=int.Parse(textBox1.Text);
int cr = int.Parse(textBox2.Text);
if(checkBox1.Checked==true)//hinh hop
{
int cc = int.Parse(textBox3.Text);
HH a = new HH(cd, cr, cc);
label4.Text= a.xuatTT();
}
else
{
HCN a = new HCN(cd, cr);
label4.Text = a.xuatTT();
}
}
}
}

Comments

Popular posts from this blog

PHP#33MySQL#29 - Đếm lượt truy cập (KẾT THÚC KHÓA HỌC)

//hitcounter.php <?php session_start();  ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php  include("../connect.php"); //cập nhật số luowhtj truy cập: $sl="update counter set cnt=cnt+1"; mysqli_query($link,$sl); //Lấy dữ liệu số lượt truy cập để hiển thị ra web: $sl2="select * from counter"; $kq=mysqli_query($link,$sl2); $d=mysqli_fetch_array($kq); //Định dạng: $chuoi=str_pad($d['cnt'],6,"0",STR_PAD_LEFT); $luottrycap=""; for($i=0;$i<strlen($chuoi);$i++) { $tam=substr($chuoi,$i,1); $luottrycap.="<img src='images/$tam.png'/>"; } /*-Khi user truy cập vào website: +lần đầu tuy cập: Lưu thông tin của user lên csdl +Sau lần đầu tiên: cập nhtaaj lastvisit - Xóa các dòng dữ liệu quá 1 phút (Quy ước thời gian để khẳng định online hay offline: 1 phút) - Thống kê số liệu người dùng o...

2 (giao diện Visual C#) Solution Explorer

Bài 2 - SOME OTHER TIME - Vào dịp khác