日期:2014-05-20 浏览次数:20862 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TextLog log = new TextLog();
log.message = "删除用户";
log.Write();
PriorityLog plog = new PriorityLog(log);
plog.level = 1;
plog.Write();
ErrorLog elog = new ErrorLog(plog);
elog.level = 2;
elog.Write();
Console.ReadKey();
}
}
abstract class Log
{
public string message;
abstract public void Write();
}
class TextLog : Log
{
public override void Write()
{
Console.WriteLine();
Console.Write(message);
}
}
class PriorityLog : Log
{
Log _log;
public int? level;
public PriorityLog(Log log)
{
_log = log;
}