Skip to content

Instantly share code, notes, and snippets.

@Haraguroicha
Last active December 25, 2015 04:49
Show Gist options
  • Save Haraguroicha/6919730 to your computer and use it in GitHub Desktop.
Save Haraguroicha/6919730 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace HanzawaNaoki {
class Program {
static void Main(string[] args) {
Console.OutputEncoding = new UnicodeEncoding();
Console.WindowWidth = 120;
Console.WriteLine(new HanzawaNaoki(1));
Console.WriteLine(new HanzawaNaoki(2));
Console.WriteLine(new HanzawaNaoki(5));
Console.WriteLine(new HanzawaNaoki(10));
Console.WriteLine(new HanzawaNaoki(7) + 6);
Console.WriteLine(new HanzawaNaoki(new HanzawaNaoki(9)));
Console.WriteLine(new HanzawaNaoki(4) + new HanzawaNaoki(3));
Console.ReadKey();
}
}
public class HanzawaNaoki {
private bool isNeedHundredReturn;
private int _rememberedValue;
private int rememberedValue {
get {
return this._rememberedValue * 10;
}
set {
this._rememberedValue = value;
}
}
public HanzawaNaoki(int t, bool hundred = false) {
this.isNeedHundredReturn = hundred;
this.rememberedValue = t;
}
public HanzawaNaoki(HanzawaNaoki hn) {
this.isNeedHundredReturn = true;
this.rememberedValue = hn.rememberedValue;
}
public static HanzawaNaoki operator + (HanzawaNaoki hn1, HanzawaNaoki hn2) {
return new HanzawaNaoki(hn1.rememberedValue + hn2.rememberedValue, true);
}
public static HanzawaNaoki operator + (HanzawaNaoki hn, int i) {
return new HanzawaNaoki(hn.rememberedValue + i * 10, true);
}
public static HanzawaNaoki operator + (int i, HanzawaNaoki hn) {
return hn + i;
}
public override string ToString() {
return string.Format("有仇必報,{2}倍奉還!やられたらやり返す。{2}倍返しだ!You give me {0}, I'll give you {1}!!", this._rememberedValue, this.rememberedValue, (this.isNeedHundredReturn ? "百" : "十"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment