так же рекомендация от ментора закрыть поток чтения, хотя все через Try With Resourses
Product.class - создал класс для считываемого товара
ProductIn - класс для считывания
ProductOut - класс для вывода
собираем все в солюшене
спасибо
package com.javarush.task.task18.task1827;
public class Product {
public int getId () {
return id;
}
public void setId ( int id){
this.id = id;
}
public String getProductName () {
return productName;
}
public void setProductName (String productName){
this.productName = productName;
}
public float getPrice () {
return price;
}
public void setPrice ( float price){
this.price = price;
}
public int getQuantity () {
return quantity;
}
public void setQuantity ( int quantity){
this.quantity = quantity;
}
private int id; //8
private String productName; //30
private float price; //8
private int quantity; //4
@Override
public String toString() {
return "Product{" +
"id=" + id +
", productName='" + productName + '\'' +
", price=" + price +
", quantity=" + quantity +
'}';
}
}