//non-default constructor public TicketSums(NightlySum totals, double adultPrice, double studentPrice, double seniorPrice, double parPassPrice) { //assign values this.Adults = totals.adults; this.Students = totals.students; this.Seniors = totals.seniors; this.ParPass = totals.parPass; this.adultPrice = adultPrice; this.studentPrice = studentPrice; this.seniorPrice = seniorPrice; this.parPassPrice = parPassPrice; }
private NightlySum showTotal() { //create nightly sum to hold total NightlySum totalSum = new NightlySum(); //for each night for (int i = 1; i <= show.htNights2Nights.Count; i++) { //get the nightly sum NightlySum thisSum = (NightlySum)sumNight((Night)show.htNights2Nights[i]); //add night's sum to total sum totalSum.tickets += thisSum.tickets; totalSum.adults += thisSum.adults; totalSum.students += thisSum.students; totalSum.seniors += thisSum.seniors; totalSum.comps += thisSum.comps; totalSum.parPass += thisSum.parPass; }//end for //return the total return totalSum; }
private void updateNightLabels(NightlySum sum) { //create object to perform math. more for cleanliness than anything else TicketSums sums = new TicketSums(sum, Ticket.adultCost, Ticket.studentCost, Ticket.seniorCost, Ticket.parPassCost); //assign the values to the labels lblNightTixTot1.Text = sum.tickets.ToString(); lblNightAdTix1.Text = sum.adults.ToString(); lblNightStudTix1.Text = sum.students.ToString(); lblNightSenTix1.Text = sum.seniors.ToString(); lblNightCompTix1.Text = sum.comps.ToString(); lblNightParPassTix1.Text = sum.parPass.ToString(); lblNightTaken1.Text = "$ " + String.Format("{0:0.00}", sums.total()); lblNightSenTaken1.Text = "$ " + String.Format("{0:0.00}", sums.totalSenior()); lblNightAdTaken1.Text = "$ " + String.Format("{0:0.00}", sums.totalAdult()); lblNightStudTaken1.Text = "$ " + String.Format("{0:0.00}", sums.totalStudent()); }
private NightlySum sumNight(Night nightTable) { //declare placeholders int tickets = 0; int adults = 0; int students = 0; int seniors = 0; int comps = 0; int parPass = 0; foreach (string key in SeatNumbers.seatNums) { //create a local object for each seat Seat seat = (Seat)nightTable.htSeats2Bits[key]; //no need to include it if it is not reserved if (seat.reserved == true) { //increment total tickets++; //increment each type if (seat.ticket.type == "Adult") { adults++; }//end if else if (seat.ticket.type == "Student") { students++; }//end if else if (seat.ticket.type == "Senior") { seniors++; }//end if else if (seat.ticket.type == "Comp") { comps++; }//end if else if (seat.ticket.type == "Parent Pass") { parPass++; }//end if }//end outer if }//end foreach //create a new object to hold the sum NightlySum sum = new NightlySum(tickets, adults, students, seniors, comps, parPass); //return that object return sum; }