Created
October 3, 2018 21:12
-
-
Save PhiHuyHoang/7156103030d3ce67b754b631a077d89a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Thing | |
{ | |
private int price; | |
private string detail; | |
public int Price { get => price; set => price = value; } | |
public string Detail { get => detail; set => detail = value; } | |
public Thing(int price, string detail) | |
{ | |
this.price = price; | |
this.detail = detail; | |
} | |
public virtual void Plus(Thing something) | |
{ | |
price += something.price; | |
detail += ", " + something.detail; | |
} | |
} | |
class Party : Thing | |
{ | |
public Party(int price = 200, string detail = "Party") : base(price, detail) | |
{ | |
} | |
} | |
class Alcohol : Thing | |
{ | |
public Alcohol(int price = 50, string detail = "Alcohol") : base(price, detail) | |
{ | |
} | |
} | |
class Girl : Thing | |
{ | |
public Girl(int price = 1000, string detail = "Girl") : base(price, detail) | |
{ | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Party A = new Party(); | |
Alcohol B = new Alcohol(); | |
Girl C = new Girl(); | |
Console.WriteLine($"{A.Detail}"); | |
Console.WriteLine($"{A.Price}"); | |
A.Plus(B); | |
Console.WriteLine($"{A.Detail}"); | |
Console.WriteLine($"{A.Price}"); | |
A.Plus(C); | |
Console.WriteLine($"{A.Detail}"); | |
Console.WriteLine($"{A.Price}"); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment