Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.*;
- import java.util.Scanner;
- /**
- @author Snilledata
- */
- public class ATMClient {
- private static int connectionPort = 8989;
- static DataInputStream in = null;
- static DataOutputStream out = null;
- static Socket ATMSocket = null;
- private static final byte ASSIGNMENT_LOGIN = 0x01;
- private static final byte ASSIGNMENT_WITHDRAWAL = 0x02;
- private static final byte ASSIGNMENT_DEPOSIT = 0x03;
- private static final byte ASSIGNMENT_BALANCE = 0x04;
- public static void main(String[] args) throws IOException {
- String adress = "";
- try {
- adress = args[0];
- } catch (ArrayIndexOutOfBoundsException e) {
- System.err.println("Missing argument ip-adress");
- System.exit(1);
- }
- try {
- ATMSocket = new Socket(adress, connectionPort);
- in = new DataInputStream(ATMSocket.getInputStream());
- out = new DataOutputStream(ATMSocket.getOutputStream());
- } catch (UnknownHostException e) {
- System.err.println("Unknown host: " +adress);
- System.exit(1);
- } catch (IOException e) {
- System.err.println("Couldn't open connection to " + adress);
- System.exit(1);
- }
- System.out.println("Contacting bank ... ");
- System.out.println(get());
- //Scanner scanner = new Scanner(System.in);
- System.out.print("> ");
- /* int menuOption = scanner.nextInt();
- int userInput;
- out.println(menuOption);
- while(menuOption < 2) {
- if(menuOption == 1) {
- System.out.print("> ");
- menuOption = scanner.nextInt();
- out.println(menuOption);
- } else if (menuOption > 2) {
- break;
- } else {
- System.out.println(in.readLine());
- userInput = scanner.nextInt();
- out.println(userInput);
- String str;
- do {
- str = in.readLine();
- System.out.println(str);
- } while (!str.startsWith("(1)"));
- System.out.print("> ");
- menuOption = scanner.nextInt();
- out.println(menuOption);
- }
- } */
- out.close();
- in.close();
- ATMSocket.close();
- }
- //bör använda sig av "DataInputStream"
- private static void send(byte instr, String params) {
- }
- //bör använda sig av "DataInputStream"
- private static String get() throws IOException{
- return null;
- }
- }
Add Comment
Please, Sign In to add comment