Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import com.rethinkdb.RethinkDB;
- import com.rethinkdb.gen.exc.ReqlError;
- import com.rethinkdb.gen.exc.ReqlQueryLogicError;
- import com.rethinkdb.model.MapObject;
- import com.rethinkdb.net.Connection;
- import static org.ap.Database.r;
- public class UserInput {
- public static Double[] grabInput(){
- Connection conn = r.connection().hostname("Private").port(28015).connect();
- Scanner scan = new Scanner(System.in);
- //Decide what the scanner will be looking for
- System.out.print("What action will you be completing?: ");
- String action = scan.nextLine();
- //Scans For Action Requests
- if (action.equals("Login")){
- //Login Action
- System.out.print("Username: ");
- String username = scan.nextLine();
- System.out.print("Password: ");
- String password = scan.nextLine();
- //Login Validation
- if (r.db("APSCI").table("BankAccounts").filter(row ->
- row.g("username").eq(username).and(row.g("password").eq(password))).coerceTo("BOOL").run(conn)){
- System.out.print("Welcome /n (username)");
- }
- else {
- System.out.print("No User Was Found!");
- }
- }
- if (action.equals("Numbers")){
- //Decide the number of numbers to be used in the array
- System.out.print("Enter how many numbers you will input: ");
- Integer numOfNumbers = Integer.parseInt(scan.nextLine());
- //Create a string array to store the numbers that will be used
- Double arrayOfNumbers[] = new Double[numOfNumbers];
- for (int i = 0; i < arrayOfNumbers.length; i++) {
- System.out.print("Enter the number " + (i+1) + " : ");
- arrayOfNumbers[i] = Double.parseDouble(scan.nextLine());
- }
- //Now show your numbers
- System.out.print("My numbers : ");
- System.out.print(arrayOfNumbers[0]);
- for (int i = 1;i < arrayOfNumbers.length;i++) {
- System.out.print(" , " + arrayOfNumbers[i]);
- }
- System.out.println();
- return arrayOfNumbers;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement