using System;
using System.Collections.Generic;
using System.Text;
namespace text2
{
class Program
{
static void Main(string[] args)
{
NewBook MyNovel = new NewBook("China", "Ro", 500);
MyNovel.ShowBook();
}
//定义接口
public interface IBook
{
void ShowBook();
string GetTitle();
int GetPages();
void SetPages(int pages);
}
//继承接口
public class NewBook : IBook
{
public string title;
public int pages;
public string author;
public NewBook(string title, string author, int pages)
{
this.title = title;
this.author = author;
this.pages = pages;
}
public string GetTitle()
{
return title;
}
public int GetPages()
{
return pages;
}
public void SetPages(int pages)
{
this.pages = pages;
}
public void ShowBook()
{
Console.WriteLine("Title:{0}", title);
Console.WriteLine("Author:{0}", author);
Console.WriteLine("Pages:{0}", pages);
}
}
}
}
代码的思想 流程。