add overriding
This commit is contained in:
parent
71fb61f6dc
commit
0c80706a4b
@ -38,7 +38,7 @@ namespace TicketSystem
|
||||
price += t.price;
|
||||
break;
|
||||
case TicketType.Adult:
|
||||
t = new Adult();
|
||||
t = new Ticket();
|
||||
tickets.Add(t);
|
||||
price += t.price;
|
||||
break;
|
||||
|
@ -42,7 +42,6 @@
|
||||
<Compile Include="Order.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tickets\Adult.cs" />
|
||||
<Compile Include="Tickets\Child.cs" />
|
||||
<Compile Include="Tickets\Student.cs" />
|
||||
<Compile Include="Tickets\Ticket.cs" />
|
||||
|
@ -1,17 +0,0 @@
|
||||
namespace TicketSystem.Tickets
|
||||
{
|
||||
public class Adult: Ticket
|
||||
{
|
||||
public int price { get; }
|
||||
|
||||
public Adult()
|
||||
{
|
||||
price = 20;
|
||||
}
|
||||
|
||||
public int PriceWithReduction()
|
||||
{
|
||||
return price - price/100*20;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,9 +7,17 @@
|
||||
Adult
|
||||
}
|
||||
|
||||
public interface Ticket
|
||||
public class Ticket
|
||||
{
|
||||
int price { get; }
|
||||
int PriceWithReduction();
|
||||
public int price { get; }
|
||||
public Ticket()
|
||||
{
|
||||
price = 20;
|
||||
}
|
||||
|
||||
public int PriceWithReduction()
|
||||
{
|
||||
return price - price/100*20;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user