Guest User

tangian mo

a guest
Nov 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. ------- TICKET
  2. /**
  3. @author Christopher Lawrence L. Nigoza (193572)
  4. @version 14 November 2019
  5. **/
  6.  
  7. /*
  8. I have not discussed the Java language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.
  9.  
  10. I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
  11.  
  12. If any Java language code or documentation used in my program was obtained from another source, such as a textbook or website, that has been clearly noted with a proper citation in the comments of my program.
  13.  
  14. */
  15.  
  16. public class Ticket {
  17. private double credit;
  18. public Ticket(boolean isSVT){
  19. if (isSVT == true) {
  20. credit = 150.00;
  21. } else {
  22. credit = 0.00;
  23. }
  24. public void deductFare(double amount){
  25. credit -= amount;
  26. }
  27. public void topUp(double amount){
  28. credit += amount;
  29. }
  30. public double getCredit(){
  31. return credit;
  32. }
  33. public boolean isStoredValue(){
  34. return isSVT;
  35. }
  36. }
  37. }
  38.  
  39. -------- TICKET GATE
  40. /**
  41. @author Christopher Lawrence L. Nigoza (193572)
  42. @version 14 November 2019
  43. **/
  44.  
  45. /*
  46. I have not discussed the Java language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.
  47.  
  48. I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
  49.  
  50. If any Java language code or documentation used in my program was obtained from another source, such as a textbook or website, that has been clearly noted with a proper citation in the comments of my program.
  51.  
  52. */
  53.  
  54. public class TicketGate {
  55. private double rev;
  56. private int lastRBonus;
  57. private int svCount;
  58. private int sjCount;
  59. public TicketGate(){
  60. svCount = 0;
  61. sjCount = 0;
  62. lastRBonus = 0;
  63. rev = 0;
  64. }
  65. public void collectFare(Ticket currentTicket, double fare){
  66. if (Ticket == true){
  67. rev += fare;
  68. svCount++;
  69. if (credit < fare){
  70. rev += (credit - fare);
  71. lastRBonus++;
  72. System.out.println("You have used your Last Ride Bonus. Your remaining credit of PHP" + credit + "has been collected. Please top up soon.");
  73. }
  74. if (credit == 0.00){
  75. System.out.println("You are not eligible for the Last Ride Bonus as your remaining credit is PHP 0.00. Please top up then try again.");
  76. }
  77. System.out.println("Thank you for using your Stored-Value Ticket.");
  78. System.out.println("You have paid PHP" + fare + "in fare. Your remaining stored credit is PHP" + credit + ".");
  79. } else {
  80. rev += fare;
  81. sjCount++;
  82. System.out.println("Single-Journey Ticket: You paid PHP" + fare + "in fare.");
  83. }
  84. }
  85. public double getCollections(){
  86. return rev;
  87. }
  88. public int getSJT(){
  89. return sjCount;
  90. }
  91. public int getSVT(){
  92. return svCount;
  93. }
  94. public int getBonuses(){
  95. return lastRBonus;
  96. }
  97. }
  98.  
  99. -------- RAIL STATION
  100. /**
  101. @author Christopher Lawrence L. Nigoza (193572)
  102. @version 14 November 2019
  103. **/
  104.  
  105. /*
  106. I have not discussed the Java language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.
  107.  
  108. I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
  109.  
  110. If any Java language code or documentation used in my program was obtained from another source, such as a textbook or website, that has been clearly noted with a proper citation in the comments of my program.
  111.  
  112. */
  113.  
  114. public class RailStation {
  115. public RailStation(int numGates){
  116. ArrayList<String> gates
  117. numGates = new TicketGate[MAX];
  118. gates.add(numGates);
  119. System.out.println("RailStation created.");
  120. public void addTicket (Ticket t){
  121. ArrayList<String> tickets
  122. tickets.add(t);
  123. public void addTicketGate(){
  124. if (numGates < MAX) {
  125. gates[numGates] = new TicketGate();
  126. numGates++;
  127. System.out.println("TicketGate added.");
  128. } else {
  129. System.out.println("Cannot add new TicketGate.");
  130. }
  131. public void collectFare (int gateNum, int ticketNum, double fare){
  132. gates[gateNum].collectFare(tickets[ticketNum], fare);
  133. }
  134. public void topUp (int ticketNum, double amount){
  135. topUp(tickets[ticketNum], amount);
  136. }
  137. public void printReport(){
  138.  
  139. }
  140.  
  141. ----------- RAIL STATION CONSOLE
  142.  
  143. /**
  144.  
  145. @author Christopher Lawrence L. Nigoza (193572)
  146. @version 14 November 2019
  147.  
  148. **/
  149.  
  150. /*
  151. I have not discussed the Java language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.
  152.  
  153. I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
  154.  
  155. If any Java language code or documentation used in my program was obtained from another source, such as a textbook or website, that has been clearly noted with a proper citation in the comments of my program.
  156.  
  157. */
  158.  
  159. import java.util.*;
  160. public class RailStationConsole {
  161. public static void main(String[] args) {
  162. Scanner input = new Scanner(System.in);
  163.  
  164. RailStation rail1 = new RailStation();
  165. while (true) {
  166. String inp1 = input.next();
  167. Int inp2 = input.nextInt();
  168. Int inp3 = input.nextInt();
  169. Double inp4 = input.nextDouble();
  170.  
  171. }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment