Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.net.*;
- import java.util.*;
- public class clientN {
- public static void main ( String[] args)
- {
- try {
- InetAddress addr = InetAddress.getByName("localhost");
- Socket s = new Socket(addr,5000);
- PrintStream writer = new PrintStream(s.getOutputStream(),true);
- InputStreamReader reader = new InputStreamReader(s.getInputStream());
- BufferedReader read = new BufferedReader(reader);
- int temp;
- do
- {
- System.out.println("Aggiungi scelta : ");
- Scanner input = new Scanner(System.in);
- String inputValue = new String(input.nextLine());
- temp = Integer.parseInt(inputValue);
- writer.println(inputValue);
- switch(temp)
- {
- case 1 :
- //inserimento negozio
- System.out.println("Aggiugi negozio :");
- String shopName = input.nextLine();
- writer.println(shopName);
- System.out.println(read.readLine());
- break;
- case 2 :
- //eliminazione negozio
- System.out.println("Negozio da eliminare :");
- String shopNameToDelete = input.nextLine();
- writer.println(shopNameToDelete);
- System.out.println(read.readLine());
- break;
- case 3:
- //inserimento prodotto
- System.out.println("Nome del negozio prodotto: ");
- String addShopName = new String(input.nextLine());
- System.out.println("Nome del prodotto: ");
- String productName = new String(input.nextLine());
- writer.println(addShopName);
- writer.println(productName);
- System.out.println(read.readLine());
- break;
- case 4:
- //eliminazione prodotto
- System.out.println("Nome del negozio da cui eliminare: ");
- String shopToDelete = new String(input.nextLine());
- System.out.println("Nome del prodotto da eliminare: ");
- String productNameToDelete = new String(input.nextLine());
- writer.println(shopToDelete);
- writer.println(productNameToDelete);
- System.out.println(read.readLine());
- break;
- }
- }while(temp != 0);
- writer.close();
- s.close();
- System.out.println("Arrivederci!");
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement