Last active
October 8, 2015 03:34
-
-
Save MerrittMelker/feab78ecb0d039b8bf30 to your computer and use it in GitHub Desktop.
superpus potential example
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
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Tribune | |
{ | |
public abstract class Tribune | |
{ | |
public abstract Ticket[] BuyTicket(int amtAdults, int amtChildren); | |
} | |
public class StandTribune : Tribune | |
{ | |
public Ticket[] BuyTicket(int amtAdults, int amtChildren) | |
{ | |
int amtTickets = amtAdults + amtChildren; | |
if (SellPlace(amtTickets)) | |
{ | |
StandTicket[] res = new StandTicket[amtTickets]; | |
for (int i = 0; i < amtAdults; i++) | |
{ | |
res[i] = new StandTicket(Name, Price); | |
} | |
for (int i = amtAdults; i < amtTickets; i++) | |
{ | |
res[i] = new StandTicket(Name, Childprice); | |
} | |
AmtAdults += amtAdults; | |
AmtChildren += amtChildren; | |
return res; | |
} | |
else return null; | |
} | |
} | |
public class SeatTribune : Tribune | |
{ | |
public Ticket[] BuyTicket(int amtAdults, int amtChildren) | |
{ | |
int amtTickets = amtAdults + amtChildren; | |
int row; | |
int seat; | |
if (BuyPlace(amtTickets, out row, out seat)) | |
{ | |
SeatTicket[] res = new SeatTicket[amtTickets]; | |
for (int i = 0; i < amtAdults; i++) | |
{ | |
res[i] = new SeatTicket(Name, Price, row, seat + i); | |
} | |
for (int i = amtAdults; i < amtTickets; i++) | |
{ | |
res[i] = new SeatTicket(Name, Childprice, row, seat + i); | |
} | |
AmtAdults += amtAdults; | |
AmtChildren += amtChildren; | |
return res; | |
} | |
else return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment