c#面向对象程序设计操作题

上传人:第*** 文档编号:33939214 上传时间:2018-02-19 格式:DOC 页数:10 大小:161KB
返回 下载 相关 举报
c#面向对象程序设计操作题_第1页
第1页 / 共10页
c#面向对象程序设计操作题_第2页
第2页 / 共10页
c#面向对象程序设计操作题_第3页
第3页 / 共10页
c#面向对象程序设计操作题_第4页
第4页 / 共10页
c#面向对象程序设计操作题_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《c#面向对象程序设计操作题》由会员分享,可在线阅读,更多相关《c#面向对象程序设计操作题(10页珍藏版)》请在金锄头文库上搜索。

1、book类using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;namespace BookSalesabstract public class book : IPrintablepublic book()public book(string bookno, string bookname, string bublisher, string pageCount)this.bookno = bookno;this.bookname = bookname;this.bub

2、lisher = bublisher;this.pageCount = pageCount;public string bookno;private string Booknoget return bookno; set bookno = value; public string bookname;private string Booknameget return bookname; set bookname = value; public string bublisher;private string Bublisher get return bublisher; set bublisher

3、 = value; public string pageCount;private string PageCountget return pageCount; set pageCount = value; public virtual void CalcPrice(string a)float price;price = float.Parse(a) * 20;MessageBox.Show(price.ToString();public void PrintReport(string k)string a = -图书信息- + rnrn;string b = 图书编号: + this.boo

4、kno + rnrn;string d = 图书名称: + this.bookname + rnrn;string e = 出版社: + this.bublisher + rnrn;string f = 页数: + this.pageCount + rnrn;string c = 购买人: + k + rnrn;MessageBox.Show(a + b + c + d + e+f);Soundbook类using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;names

5、pace BookSalesclass soundbook : book, IPrintablepublic soundbook()public soundbook(string bookno, string bookname, string bublisher, string pageCount, string soundtype)this.bookno = bookno;this.bookname = bookname;this.bublisher = bublisher;this.pageCount = pageCount;this.soundtype = soundtype;publi

6、c string soundtype;private string Soundtypeget return soundtype; set soundtype = value; public void PrintReport(string k)string a = -图书信息- + rnrn;string b = 图书编号: + this.bookno + rnrn;string d = 图书名称: + this.bookname + rnrn; string e = 出版社: + this.bublisher + rnrn;string f = 页数: + this.pageCount + r

7、nrn;string c = 购买人: + k + rnrn;MessageBox.Show(a + b + c + d + e+f);Picturebook类using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;namespace BookSalesclass picturebook : book, IPrintablepublic picturebook()public picturebook(string bookno, string bookname, str

8、ing bublisher, string pageCount, string picturetype)this.bookno = bookno;this.bookname = bookname;this.bublisher = bublisher;this.pageCount = pageCount;this.picturetype = picturetype;public string picturetype;private string Picturetypeget return picturetype; set picturetype = value; public void Prin

9、tReport(string k)string a = -图书信息- + rnrn;string b = 图书编号: + this.bookno + rnrn;string d = 图书名称: + this.bookname + rnrn;string e = 出版社: + this.bublisher + rnrn;string f = 页数: + this.pageCount + rnrn;string c = 购买人: + k + rnrn;MessageBox.Show(a + b + c + d + e+f);BookSales类using System;using System.C

10、ollections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace BookSalespublic partial class BookSales : Formpublic BookSales()InitializeComponent();Dictionary Book = new Dictionary(); private void BookSales_Load(object se

11、nder, EventArgs e)picturebook aa = new picturebook(001,aa,有点,15,连环画);picturebook bb = new picturebook(002, bb, 有点, 32, 连环);soundbook cc = new soundbook(003, cc, jiaoyu, 54, xiaoren);soundbook dd = new soundbook(004, dd, 教育, 34, xiaorenwu);Book.Add(aa.bookno,aa);Book.Add(bb.bookno, bb);Book.Add(cc.bo

12、okno, cc);Book.Add(dd.bookno, dd);Disp();void Disp()listView1.Columns.Add(图书编号,100);listView1.Columns.Add(图书名称, 100);listView1.Columns.Add(出版社, 100);listView1.Columns.Add(页数,100);foreach(book mybook in Book.Values)ListViewItem item = new ListViewItem(mybook .bookno );item.SubItems.Add(mybook .bookna

13、me);item.SubItems.Add(mybook.bublisher);item.SubItems.Add(mybook.pageCount);listView1.Items.Add(item);listView1.View = View.Details;private void button1_Click(object sender, EventArgs e) picturebook mm = new picturebook(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox6.Text);Book.

14、Add(mm.bookno, mm);listView1.Clear();Disp();private void button2_Click(object sender, EventArgs e)listView2.Columns.Add(图书编号, 100);listView2.Columns.Add(图书名称, 100);listView2.Columns.Add(出版社, 100);listView2.Columns.Add(页数, 100);foreach (book mybook in Book.Values)ListViewItem item = new ListViewItem(mybook.bookno);item.SubItems.Add(mybook.bookname);item.SubItems.Add(mybook.bublisher);item.SubItems.Add(mybook.pageCount);listView2.Items.Add(item);listView2.View = View.Details;private void button

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号