Guest User

Untitled

a guest
Jun 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. Now we go over to look at the stands. It has ståtribuner and their stands. All stands have a name, capacity and price. His Terraces also has a number of seat rows. We assume that all the rows are the same length, so that the number of seats each. row is the capacity divided by the number of rows.
  2.  
  3. For ståtribunene you only need to keep track of how many seats are sold, while at their stands, one must know how many are sold on each row. We assume that the seats are sold in ascending order within each row. In addition, we assume that the program, not the buyer, determine which row to use, something you will need for the task c
  4.  
  5. Some stands are the VIP stands. There we will also keep track of the name of those who will sit on the various sites.
  6.  
  7. Task A:
  8.  
  9. Tribune classes shall have the following instance variables (not given in the exam, but are given here because you have not yet come as far as the exam):
  10.  
  11. Class Tribune:
  12.  
  13. private final String name grandstand;
  14. private final int capacity;
  15. private final int price;
  16.  
  17. The class Staa:
  18.  
  19. private int antSolgteBilletter;
  20.  
  21. Ride class:
  22.  
  23. private int [] antOpptatt / / table size: the number of rows
  24.  
  25. The class VIP:
  26.  
  27. private String [] [] spectator / / table size: the number of rows * number of seats per row
  28.  
  29. Draw a class diagram corresponding to Figure 1, for stand-classes. You will have a total of 4, or 5, stand classes. This class diagram you will not need to submit.
  30.  
  31. In the following we assume that all instance variables are private. Constructors and access methods need to program as you need them.
  32.  
  33. Task B:
  34.  
  35. For all stand types, we have methods to find the number of tickets sold () and find income (). Income is the price multiplied by the number of tickets sold. Programs this.
  36.  
  37. (Hint: Both of these methods should exist in the class Tribune.)
  38.  
  39. Task C:
  40.  
  41. Now you can program your ticket purchase. This will be done by creating two methods (in stand-classes), both called buy tickets (), which returns an array of ticket objects. The first method takes as parameters the number of tickets requested, the other takes as parameter a table of text strings (the name of those who will have tickets). For all stand types except the VIP stands, the two methods give the same results as method one, while the VIP grandstands method should return a zero (no one can buy a ticket on the VIP grandstands without giving names). For all types of stand is that if you want more tickets than can be processed, you get none. At its limit this stands the fact that all tickets sold in an order, should be on the same row. On ståtribuner only the total capacity and how many so far been sold, which puts limitations.
  42.  
  43. (Hint: Both buy tickets () methods to exist in the class Tribune.)
  44.  
  45. Task D:
  46.  
  47. Make a small test program where you create two ståtribuner, a regular grandstand seating and a VIP grandstand. Collect the stands in a table of type Tribune [].
  48.  
  49. Buy tickets for all the stands, and print the tickets.
  50.  
  51. For each stand, you should also print tribune's name, capacity, number of tickets sold and revenue. (You may want to have a toString () method in class Tribune do the job.)
Add Comment
Please, Sign In to add comment