mardi 6 décembre 2016

What's the best way to design a class to compose a new attribute based on another attribute?

For example: I have a class called Discount that holds an attribute called Type. Depending on Type value I need to compose this class or do something to represent the new field that can be declared as percent, value or fixed.

public class Discount {

private int id;
private Targer target;
private String promotionTag;

// Percent,Value,Fixed
private Type type;

private Long percent / value / fixed

}

What's the best way to design this class?

Aucun commentaire:

Enregistrer un commentaire