Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------- TICKET
- /**
- @author Christopher Lawrence L. Nigoza (193572)
- @version 14 November 2019
- **/
- /*
- 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.
- I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
- 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.
- */
- public class Ticket {
- private double credit;
- public Ticket(boolean isSVT){
- if (isSVT == true) {
- credit = 150.00;
- } else {
- credit = 0.00;
- }
- public void deductFare(double amount){
- credit -= amount;
- }
- public void topUp(double amount){
- credit += amount;
- }
- public double getCredit(){
- return credit;
- }
- public boolean isStoredValue(){
- return isSVT;
- }
- }
- }
- -------- TICKET GATE
- /**
- @author Christopher Lawrence L. Nigoza (193572)
- @version 14 November 2019
- **/
- /*
- 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.
- I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
- 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.
- */
- public class TicketGate {
- private double rev;
- private int lastRBonus;
- private int svCount;
- private int sjCount;
- public TicketGate(){
- svCount = 0;
- sjCount = 0;
- lastRBonus = 0;
- rev = 0;
- }
- public void collectFare(Ticket currentTicket, double fare){
- if (Ticket == true){
- rev += fare;
- svCount++;
- if (credit < fare){
- rev += (credit - fare);
- lastRBonus++;
- System.out.println("You have used your Last Ride Bonus. Your remaining credit of PHP" + credit + "has been collected. Please top up soon.");
- }
- if (credit == 0.00){
- 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.");
- }
- System.out.println("Thank you for using your Stored-Value Ticket.");
- System.out.println("You have paid PHP" + fare + "in fare. Your remaining stored credit is PHP" + credit + ".");
- } else {
- rev += fare;
- sjCount++;
- System.out.println("Single-Journey Ticket: You paid PHP" + fare + "in fare.");
- }
- }
- public double getCollections(){
- return rev;
- }
- public int getSJT(){
- return sjCount;
- }
- public int getSVT(){
- return svCount;
- }
- public int getBonuses(){
- return lastRBonus;
- }
- }
- -------- RAIL STATION
- /**
- @author Christopher Lawrence L. Nigoza (193572)
- @version 14 November 2019
- **/
- /*
- 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.
- I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
- 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.
- */
- public class RailStation {
- public RailStation(int numGates){
- ArrayList<String> gates
- numGates = new TicketGate[MAX];
- gates.add(numGates);
- System.out.println("RailStation created.");
- public void addTicket (Ticket t){
- ArrayList<String> tickets
- tickets.add(t);
- public void addTicketGate(){
- if (numGates < MAX) {
- gates[numGates] = new TicketGate();
- numGates++;
- System.out.println("TicketGate added.");
- } else {
- System.out.println("Cannot add new TicketGate.");
- }
- public void collectFare (int gateNum, int ticketNum, double fare){
- gates[gateNum].collectFare(tickets[ticketNum], fare);
- }
- public void topUp (int ticketNum, double amount){
- topUp(tickets[ticketNum], amount);
- }
- public void printReport(){
- }
- ----------- RAIL STATION CONSOLE
- /**
- @author Christopher Lawrence L. Nigoza (193572)
- @version 14 November 2019
- **/
- /*
- 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.
- I have not used Java language code obtained from another student, or any other unauthorized source, either modified or unmodified.
- 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.
- */
- import java.util.*;
- public class RailStationConsole {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- RailStation rail1 = new RailStation();
- while (true) {
- String inp1 = input.next();
- Int inp2 = input.nextInt();
- Int inp3 = input.nextInt();
- Double inp4 = input.nextDouble();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment