Though I wrote the plugin initially for personal use, now the same is available for you to use in your WordPress sites.
Link: https://wordpress.org/plugins/wp-showgithubfile/
You can either download it from the directory, or install directly within your WordPress installation. Here is a live demo of the plugin:
001
package com.company;
002
003 import java.util.Arrays;
004
005 public class Main {
006
007 public static void main(String[] args) {
008
009 // New Customer wants to buy a bottle
010 Customer customer = new Customer();
011
012 // Customer Registration
013 customer.RegisterMe("+919999999999", PhoneType.APP ); // App or SMS?
014
015 // Assuming Registration successful
016
017 // Customer requests the token using a mobile app, or by sending SMS
018 String CustomerToken = customer.giveMeAToken("695000"); // Pin code
019
020 if (CustomerToken != null) {
021 // Assuming Customer gets the token and he goes to the Outlet
022 } else {
023 // Seems there are no slots available. Try again later.
024 return;
025 }
026
027
028 // At the Outlet, sales guy is scanning the token
029 Boolean OutletVerification = new Outlet().isTheTokenShownByCustomerValid(CustomerToken);
030
031 if (OutletVerification) {
032 // Assuming the validation is success
033 System.out.println("Customer says: Wow, I got the bottle!");
034 } else {
035 System.out.println("Sales guy says: Get lost!");
036 }
037 }
038
039 public enum PhoneType { APP, SMS };
040
041 private static class VQServer {
042 // Database
043 public String[] tokenDB = { "A", "B","C","D","E" };
044 public String[] Outlets = {"Outlet1", "Outlet2", "Outlet3"};
045
046 public void registerCustomer(String phoneNumber, PhoneType phonetype) {
047 // Register customer
048
049 }
050 public String requestNewTokenByCustomer(String pinCode) {
051 // Logic for - Token generation logic
052 // Logic for - Find nearest outlet using pinCode
053
054 // Send token by SMS if PhoneType is SMS
055
056 return "C"; // Sample token
057 }
058
059 public Boolean validateTokenByOutlet(String token) {
060 return Arrays.asList(tokenDB).contains(token); // Validate
061 }
062 };
063
064 static VQServer vqServer = new VQServer();
065
066 private static class Customer {
067
068 public String giveMeAToken(String pinCode) {
069 return vqServer.requestNewTokenByCustomer(pinCode);
070 }
071 public void RegisterMe(String phoneNumber, PhoneType phonetype) {
072 // Customer Registration
073 vqServer.registerCustomer(phoneNumber, phonetype);
074 }
075 }
076 private static class Outlet {
077 public Boolean isTheTokenShownByCustomerValid(String token) {
078 return vqServer.validateTokenByOutlet(token);
079 }
080 }
081 }
View in GitHub | Made with wp-showgithubfile plugin
002
003 import java.util.Arrays;
004
005 public class Main {
006
007 public static void main(String[] args) {
008
009 // New Customer wants to buy a bottle
010 Customer customer = new Customer();
011
012 // Customer Registration
013 customer.RegisterMe("+919999999999", PhoneType.APP ); // App or SMS?
014
015 // Assuming Registration successful
016
017 // Customer requests the token using a mobile app, or by sending SMS
018 String CustomerToken = customer.giveMeAToken("695000"); // Pin code
019
020 if (CustomerToken != null) {
021 // Assuming Customer gets the token and he goes to the Outlet
022 } else {
023 // Seems there are no slots available. Try again later.
024 return;
025 }
026
027
028 // At the Outlet, sales guy is scanning the token
029 Boolean OutletVerification = new Outlet().isTheTokenShownByCustomerValid(CustomerToken);
030
031 if (OutletVerification) {
032 // Assuming the validation is success
033 System.out.println("Customer says: Wow, I got the bottle!");
034 } else {
035 System.out.println("Sales guy says: Get lost!");
036 }
037 }
038
039 public enum PhoneType { APP, SMS };
040
041 private static class VQServer {
042 // Database
043 public String[] tokenDB = { "A", "B","C","D","E" };
044 public String[] Outlets = {"Outlet1", "Outlet2", "Outlet3"};
045
046 public void registerCustomer(String phoneNumber, PhoneType phonetype) {
047 // Register customer
048
049 }
050 public String requestNewTokenByCustomer(String pinCode) {
051 // Logic for - Token generation logic
052 // Logic for - Find nearest outlet using pinCode
053
054 // Send token by SMS if PhoneType is SMS
055
056 return "C"; // Sample token
057 }
058
059 public Boolean validateTokenByOutlet(String token) {
060 return Arrays.asList(tokenDB).contains(token); // Validate
061 }
062 };
063
064 static VQServer vqServer = new VQServer();
065
066 private static class Customer {
067
068 public String giveMeAToken(String pinCode) {
069 return vqServer.requestNewTokenByCustomer(pinCode);
070 }
071 public void RegisterMe(String phoneNumber, PhoneType phonetype) {
072 // Customer Registration
073 vqServer.registerCustomer(phoneNumber, phonetype);
074 }
075 }
076 private static class Outlet {
077 public Boolean isTheTokenShownByCustomerValid(String token) {
078 return vqServer.validateTokenByOutlet(token);
079 }
080 }
081 }