開発環境
- Microsoft Windows 7 Home Premium (OS)
- Microsoft Visual C# 2010 Express Edition (IDE)
- 言語: C#
『初めてのC# 第2版』(Jesse Liberty+Brian MacDonald著、日向俊二訳、オライリー・ジャパン、2006年、ISBN978-487311-294-7)の 第6章(オブジェクト指向プログラミング)6.8(練習問題)問題6-2を解いてみる。
その他参考書籍
問題6-2.
コード
using System;
class Book
{
private string title;
private string author;
private Int64 isbn;
public Book(string title, string author, Int64 isbn)
{
this.title = title;
this.author = author;
this.isbn = isbn;
}
public void Read()
{
Console.WriteLine("本を読みました。");
}
public void Shelve()
{
Console.WriteLine("書棚に保管しました。");
}
}
class Tester
{
public void Run()
{
Book lcs = new Book("初めてのC#", "日向俊二 訳", 487311294);
lcs.Read();
lcs.Shelve();
}
static void Main()
{
Tester t = new Tester();
t.Run();
}
}
入出力結果(Console Window)
本を読みました。 書棚に保管しました。 続行するには何かキーを押してください . . .
0 コメント:
コメントを投稿