Skip to content

Instantly share code, notes, and snippets.

@viveknarang
Created February 12, 2018 19:26
Show Gist options
  • Save viveknarang/563601825d8a76be9db811d6a1934b38 to your computer and use it in GitHub Desktop.
Save viveknarang/563601825d8a76be9db811d6a1934b38 to your computer and use it in GitHub Desktop.
public void printTicket(int destinationNumber) // method signature, method name, public - accessibility
// of the method from external classes
{
if (destinationNumber == 1) {
if (balance < price1) {
System.out.println("Please insert " + (price1 - balance) + " more dollars.");
} else {
System.out.println("************************");
System.out.println("********MARTA********");
System.out.println("******RED LINE******");
System.out.println("****Cost :" + price1 + "dollars ****");
System.out.println("****Destination : " + destination1 + "****");
System.out.println("*************************");
balance = balance - price1;
moneyCollections = moneyCollections + price1;
}
} else {
if (balance < price2) {
System.out.println("Please insert " + (price2 - balance) + " more dollars.");
} else {
System.out.println("************************");
System.out.println("********MARTA********");
System.out.println("******RED LINE******");
System.out.println("****Cost : " + price2 + " dollars ****");
System.out.println("****Destination : " + destination2 + " ****");
System.out.println("*************************");
balance = balance - price2;
moneyCollections = moneyCollections + price2;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment