11-1.cs

来自「这是学习java基础的好的源代码的学习资料」· CS 代码 · 共 52 行

CS
52
字号
//程序11-1
using System;
interface IDistributable
{
	void Distribute();
}
interface ISalable
{
	void Sale();
}
public class Print
{
	protected int num;
	protected double prc;
	public Print(){}
	public Print(int n, double p)
	{
		num=n;
		prc=p;
	}
	public void Publish ()
	{
		Console.WriteLine("Number: {0}, Price: ¥{1} ",num,prc);
	}
}
public class LectureNotes :Print, IDistributable, ISalable
{
	protected string Name;
	public LectureNotes(){}
	public LectureNotes(string nm,int n, double p):base(n,p)
	{
			Name = nm; 
		//在基类构造函数中完成:
		// num=n;	prc=p;
	}
	public void Notes(){Console.WriteLine("The LectureNotes is "+Name);}
	public void Distribute(){Console.WriteLine("Distributed in campus only.");}
	public void Sale(){Console.WriteLine("Sale on cost.");}
}

public class Test
{
	public static void Main()
	{
		LectureNotes LN = new LectureNotes("C# Programming", 400, 28.6);
		LN.Notes();
		LN.Distribute();
		LN.Sale();
		LN.Publish();
		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?