Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- ArrayList<FabrykaProdukt> produkty = new ArrayList<>();
- while (true) {
- System.out.print("Podaj nazwę i cenę");
- FabrykaProdukt f1 = new FabrykaProdukt(sc.nextLine(), Double.parseDouble(sc.next()));
- produkty.add(f1);
- if (sc.next().equals("q")) {
- break;
- }
- }
- System.out.println(produkty);
- for (int i = 0; i < produkty.size(); i++) {
- System.out.println(produkty(i);
- }
- }
- }
- /**
- * Created by Adas on 2015-06-22.
- */
- public class FabrykaProdukt {
- String nazwa;
- double cena;
- FabrykaProdukt(String n, double c) {
- nazwa = n;
- cena = c;
- }
- public String toSring(){
- return nazwa;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment