Пользовательский класс для описания товара

Main

package sample;

public class Main {

	public static void main(String[] args) {
		Product phone = new Product("IPhone 5", 50, "Can call");
		Product comp = new Product();

		comp.setName("Pentium 2");
		comp.setPrice(25);
		comp.setWeight(3);

		System.out.println(phone);
		System.out.println(comp);

		System.out.println("Sales!\n" + "You can get " + phone.getName() + " only for " + phone.getPrice() / 2
				+ "$ with a 50% discount!");
	}

}

Product

package sample;

public class Product {
	private int id;
	private String name = "";
	private int price = 0;
	private String desc = "";
	private double weight;
	private static int nextID = 1;

	public Product() {
		super();
		id = nextID++;
	}

	public Product(String name, int price) {
		super();
		id = nextID++;
		this.name = name;
		this.price = price;
	}

	public Product(String name, int price, String desc) {
		super();
		id = nextID++;
		this.name = name;
		this.price = price;
		this.desc = desc;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	public int getId() {
		return id;
	}

	@Override
	public String toString() {
		String text = "Product [id=" + id + ", name=" + name + ", price=" + price;
		if (!desc.isEmpty()) {
			text += ", desc=" + desc;
		}
		if (weight != 0) {
			text += ", weight=" + weight;
		}
		return text + "]";
	}

}

Предложенное вами решение верно