Skip to content

Instantly share code, notes, and snippets.

@MerrittMelker
Last active October 8, 2015 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MerrittMelker/feab78ecb0d039b8bf30 to your computer and use it in GitHub Desktop.
Save MerrittMelker/feab78ecb0d039b8bf30 to your computer and use it in GitHub Desktop.
superpus potential example
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