add overriding

This commit is contained in:
Hugo Meens 2023-07-01 17:01:12 +02:00
parent 71fb61f6dc
commit 0c80706a4b
4 changed files with 12 additions and 22 deletions

View File

@ -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;

View File

@ -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" />

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}