大家來看看啊!這咋整?
編寫一個程序來記錄書店存貨清單。這個書店從出版商那訂購普通版本書和教科書。程序應該定義一個抽象類Book,它包含有MustOverride屬性,並且有普通屬性Quantity,Name和Cost。類TextBook和TradeBook應該從類Book中派生出來,並且因提價來重載屬性Price(假設普通書提價40%,教科書提價20%)程序應該允許用戶在定單上輸入,並顯示下列統計表:普通書的數量,教科書的數量,所有定單的費用和全部存貨清單的價值(存貨清單的價值是如果將書店中的所有書賣完所得的錢的數量)下面是偶寫到一半的程序```實在不知道應該怎麼寫了,各位高手幫幫我吧!!!!
我的步驟是先新建空項目,再添加代碼文件。謝謝了!!!!
using System;
using System.Windows.Forms;
abstract class Book
{
private double Q;
private string N;
private float C;
public Book() { }
public Book(double q, string n, float c)
{
Q = q; N = n; C = c;
}
public abstract double MustOverride
{
get;
set;
}
public double Quantity
{
get { return Q; }
set { Q = value; }
}
public string Name
{
get { return N; }
set { N = value; }
}
public float Cost
{
get { return C; }
set { C = value; }
}
}
public class TextBook : Book
{
public TextBook() { }
public TextBook(double Q, string N, float C)
: base(Q, N, C)
{ }
public override double MustOverride
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public override string ToString()
{
return base.ToString("+Q+","+N+","+C+");
}
}
public class TradeBook : Book
{
public TradeBook() { }
public TradeBook(double Q, string N, float C)
: base(Q, N, C)
{ }
public override double MustOverride
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public override string ToString()
{
return base.ToString("+Q+","+N+","+C+");
}
}
public class MainClass
{
public static void Main()
{
string output;
}
}
[此贴子已经被作者于2006-11-19 16:43:14编辑过]