objects…get oriented! Making code make sense - while loop, if/else, boolean, true, false
Head First C#: A Learner’s Guide to Real-World Programming with C# and .NET Core (Andrew Stellman(著)、Jennifer Greene(著)、O’Reilly Media)のChapter 3(objects…get oriented! Making code make sense)、p.153(Sharpen your pencil)の解答を求めてみる。
コード
using System;
namespace MyFirstConsoleApp
{
class Program
{
static void Main(string[] args)
{
Pizzazz foxtrot = new Pizzazz() { Zippo = 2 };
foxtrot.Bamboo(foxtrot.Zippo);
Pizzazz november = new Pizzazz() { Zippo = 3 };
Abracadabra tango = new Abracadabra() { Vavavoom = 4 };
while (tango.Lala(november.Zippo))
{
november.Zippo *= -1;
november.Bamboo(tango.Vavavoom);
foxtrot.Bamboo(november.Zippo);
tango.Vavavoom -= foxtrot.Zippo;
}
Console.WriteLine(november.Zippo == 4);
Console.WriteLine(foxtrot.Zippo == 8);
Console.WriteLine(tango.Vavavoom == -1);
}
}
}
// fox nov tan
// 4 3 4
// 4 3 7
// 4 -3 7
// 4 4 7
// 8 4 7
// 8 4 -1
入出力結果(Terminal)
True
True
True