Guest User

Untitled

a guest
Apr 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. //***************************************
  2. // Verteilte Systeme Praktikum 7
  3. // 03.12.11 mteppner, vkoschmann
  4. // News Client
  5. //***************************************
  6.  
  7.  
  8. import java.net.MalformedURLException;
  9. import java.rmi.Naming;
  10. import java.rmi.RemoteException;
  11. import java.rmi.NotBoundException;
  12. import java.rmi.*;
  13. import java.io.*;
  14.  
  15.  
  16. public class Client {
  17.  
  18.     /**
  19.      * @param args
  20.      * @throws IOException
  21.      */
  22.     public static void main(String[] args) throws IOException {
  23.         try {
  24.             NewsServer ns = (NewsServer) Naming.lookup("rmi://localhost:1099/NewsServerService");
  25.        
  26.             System.out.println("Login, Bitte nickname eingeben --> ");
  27.             InputStreamReader isr = new InputStreamReader(System.in);
  28.             BufferedReader br = new BufferedReader(isr);
  29.             String name = br.readLine();
  30.            
  31.             ns.login(name);
  32.  
  33.             while(true){
  34.                 System.out.println();
  35.                 System.out.println("NewsClient-Menue");
  36.                 System.out.println("======================");
  37.                 System.out.println("(1) Neue News anzeigen");
  38.                 System.out.println("(2) Neue News erstellen");
  39.                 System.out.println("(0) Beenden");
  40.                 System.out.println();
  41.                 System.out.println("--> ");
  42.                 String choice = br.readLine();
  43.                 int c = Integer.parseInt(choice);
  44.                
  45.                 if(c == 1){
  46.                     //showNew
  47.                 }
  48.                 else if(c == 2){
  49.                     //create
  50.                 }
  51.                 else if(c == 0){
  52.                     System.out.println("Programm wird beendet");
  53.                     break;
  54.                 }
  55.                 else{
  56.                     System.out.println("Ungueltige Eingabe");
  57.                 }
  58.                
  59.             }
  60.         } catch (RemoteException re) {
  61.             System.out.println();
  62.             System.out.println("RemoteException");
  63.             System.out.println(re);
  64.         } catch (NotBoundException nbe) {
  65.             System.out.println();
  66.             System.out.println("NotBoundException");
  67.             System.out.println(nbe);
  68.         }catch(java.lang.ArithmeticException ae) {
  69.             System.out.println();
  70.             System.out.println("java.lang.ArithmeticException");
  71.             System.out.println(ae);
  72.         }
  73.     }
  74. }
Add Comment
Please, Sign In to add comment