Не могу найти ошибку, проверял на реальном файле, все хорошо добавляет, пробелы дописываются, форматирование совпадает! Но никак!!!
Помогите пожалуйста!
package com.javarush.task.task18.task1827;
public class Product
{
private String id;
private String productName;
private String price;
private String quantity;
public Product(String productName, String price, String quantity)
{
int nameLength = productName.toCharArray().length;
int priceLength = (price+"").toCharArray().length;
int quantityLength = quantity.toCharArray().length;
if (nameLength<=30)
{
for (int i = 0; i < (30-nameLength); i++)
{
productName+=" ";
}
this.productName = productName;
} else {System.out.println("Слишком длинное имя");}
if (priceLength<=8){
for (int i = 0; i < (8-priceLength); i++)
{
price+=" ";
}
this.price = price;
} else {System.out.println("Слишком много знаков в цене");}
if (quantityLength<=8){
for (int i = 0; i < (4-quantityLength); i++)
{
quantity+=" ";
}
this.quantity = quantity;
} else {System.out.println("Слишком много знаков в цене");}
}
public void setId (String id)
{
int idLength = id.toCharArray().length;
if (idLength<=8){
for (int i = 0; i < (8-idLength); i++)
{
id+=" ";
}
this.id = id;
} else {System.out.println("Слишком много знакоd");}
}
public String getId ()
{
return id;
}
public String getProductName ()
{
return productName;
}
public String getPrice ()
{
return price;
}
public String getQuantity ()
{
return quantity;
}
}