Advertisement
Guest User

Server class

a guest
Apr 15th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.io.*;
  2. import java.net.*;
  3. import java.util.*;
  4.  
  5. public class NewServer
  6. {
  7. static ServerSocket server;
  8. static Socket client;
  9. static PrintStream writer;
  10. static Scanner reader;
  11.  
  12. static String username;
  13. static String password;
  14. static double balance;
  15.  
  16. public static void main
  17. (String[] args)
  18. {
  19. try
  20. {
  21. server = new
  22. ServerSocket(9999);
  23. client = server.accept();
  24. writer = new PrintStream
  25. (client.getOutputStream());
  26. reader = new Scanner
  27. (client.getInputStream());
  28.  
  29. getBalance();
  30. }
  31. catch (IOException IOex)
  32. {
  33. IOex.printStackTrace();
  34. }
  35. }
  36.  
  37. public void getBalance()
  38. {
  39. username = reader.next();
  40. password = reader.next();
  41. if (password.equals(“guest”))
  42. balance = 100.00;
  43. else
  44. balance = 10.00;
  45. writer.println(balance);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement