package sklep.klient;

import java.util.List;
import java.util.Scanner;

import sklep.generated.*;

public class Klient2_OdczytajJedenProdukt {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		SklepService service = new SklepService();
		Sklep sklep = service.getSklepPort();
		
		while(true)	{
			System.out.print("\nPodaj id produktu: ");
			int id = scanner.nextInt();
			if(id == 0) break;
			try {
				Product product = sklep.odczytajJedenProdukt(id);
				System.out.println(product.getName() + " za " + product.getPrice());
				System.out.println("Opis: " + product.getDescription());
			} catch (RecordNotFound_Exception e) {
				System.out.println("Nie ma takiego numeru.");
			} catch (DBException_Exception e) {
				System.out.println("Inny błąd: " + e);
				e.printStackTrace();
			}
		}
	}

}
