Guest User

Untitled

a guest
Jun 22nd, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8. ArrayList<FabrykaProdukt> produkty = new ArrayList<>();
  9. while (true) {
  10. System.out.print("Podaj nazwę i cenę");
  11. FabrykaProdukt f1 = new FabrykaProdukt(sc.nextLine(), Double.parseDouble(sc.next()));
  12. produkty.add(f1);
  13. if (sc.next().equals("q")) {
  14. break;
  15. }
  16.  
  17. }
  18. System.out.println(produkty);
  19. for (int i = 0; i < produkty.size(); i++) {
  20. System.out.println(produkty(i);
  21.  
  22. }
  23. }
  24. }
  25.  
  26. /**
  27. * Created by Adas on 2015-06-22.
  28. */
  29. public class FabrykaProdukt {
  30. String nazwa;
  31. double cena;
  32. FabrykaProdukt(String n, double c) {
  33. nazwa = n;
  34. cena = c;
  35.  
  36. }
  37. public String toSring(){
  38. return nazwa;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment