请教老师大师们:基类,派生类的用法和窗体的输出
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class auto
{
public int _wheels; //车轮
public double _weight; //车重
public auto(int wheels, double weight)
{
_wheels = wheels ;
_weight = weight ;
}
int getwheels()
{
return _wheels ;
}
double getweight()
{
return _weight ;
}
}
class car : auto
{
public car(int wheels, double weight)
: base(wheels, weight)
{
}
}
class truck: auto
{
public truck(int wheels, double weight)
: base(wheels, weight)
{
}
}
class bike: auto
{
public bike(int wheels, double weight)
: base(wheels, weight)
{
}
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "轿车")
{
new car(4, 1000);
textBox1.Text = "轿车" ;
textBox2.Text = "4";
textBox3.Text = "1000";
}
else if (comboBox1.Text == "卡车")
{
new truck(12, 6000);
textBox1.Text = "卡车";
textBox2.Text = "12";
textBox3.Text = "6000";
}
else if (comboBox1.Text == "自行车")
{
new bike(2, 60);
textBox1.Text = "自行车";
textBox2.Text = "2";
textBox3.Text = "60";
}
else MessageBox.Show ("请选择你要查询的项目。");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
}
这是我的课题要求
设计一个汽车类族
要求:一个基类AUTO;
若干个派生类分别描述轿车、卡车、自行车等等。
设计相应Windows界面用于选择性地输出各种信息。
对于赋于派生类的值怎么在textbox中输出了?
要是和汉字一起输出,即把3个textbox合并成一个.不知道如何是好...