プログラミング(Python、Perl、C、Go、JavaScript)、数学、読書…
開発環境
"初めてのC# 第2版"の第6章(オブジェクト指向プログラミング)の6.8(練習問題)を解いてみる。
問題 6.1
省略。
問題 6.2
using System; public class Book { private string title; private string author; private long ISBN; public Book(string title, string author, long 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 book = new Book( "Learning C# 2005, Second Edition", "Jesse Liberty, Brian MacDonald", 9780596102098); book.Read(); book.Shelve(); } static void Main() { Tester t = new Tester(); t.Run(); } }
出力結果
本を読む 本を書棚に保管する 続行するには何かキーを押してください . . .
0 コメント:
コメントを投稿