Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Ticket[] tickets = {new Ticket("Mozart", 250.00), new Ticket("Mozart", 250.00), new DiscountTicket("Mozart", 250.00, "John Smith"), new GroupTicket("Mozart", 250.00, 20)};
- getInfo(tickets);
- }
- public static void getInfo(Ticket[] tickets) {
- int people = 0;
- double sum = 0;
- for(int i=0;i<tickets.length;i++) {
- people = people + tickets[i].getPeople();
- sum += tickets[i].getPrice();
- }
- System.out.println("Number of people from these tickets: "+people);
- System.out.println("The total sum of these tickets: "+sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement