Part 2 Guidance

Problem

Create Java classes of the business model.  Only focus on field members and the getter and setter methods.

Remember your classes will change as you progress through the case study, so try not to gold plate.

Solution


Starting Point - v01Solution - v02
Customer Class
Not available
Customer Class
public class Customer
{
    private LocalDate   dob;
    private String      address;
    private String      fname;
    private String      lname;
    private Account     itsAccount;
    
    public Customer()
    {
    }

    public  void    setAccount( Account acc )
    {
        itsAccount = acc;
    }
    
    public  Account getAccount()
    {
        return itsAccount;
    }
    
    public LocalDate getDob()
    {
        return dob;
    }

    public void setDob(LocalDate dob)
    {
        this.dob = dob;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getFname()
    {
        return fname;
    }

    public void setFname(String fname)
    {
        this.fname = fname;
    }

    public String getLname()
    {
        return lname;
    }

    public void setLname(String lname)
    {
        this.lname = lname;
    }
}
Account Class
public class Account
{
    private int account_id;
    private LocalDate date_opened;
    
    public  Account()
    {
        
    }
    
    public	void	addOrder( Order anOrder )
    {
    }
    
    public	void	getOrders()
    {
    }

    public	LocalDate	getDateCreated()
    {
            return date_opened;
    }

    public	int	getAccountId()
    {
            return account_id;
    }
}
Account Class
public class Account
{
    private int account_id;
    private LocalDate date_opened;
    
    public  Account()
    {
        
    }
    
    public	LocalDate	getDateCreated()
    {
            return date_opened;
    }
    
    public  void    setDateCreated( LocalDate date )
    {
        date_opened = date;
    }
    
    public  void    setDateCreated( String date )
    {
        date_opened = LocalDate.parse(date);
    }

    public	int	getAccountId()
    {
            return account_id;
    }
}
Order Class
public class Order
{
    private int order_no;
    private double total_cost;
    private LocalDate order_date;

    public Order()
    {
    }

    public void addItem(Item anItem)
    {
    }

    public int getOrderNo()
    {
        return order_no;
    }

    public LocalDate getDateCreated()
    {
        return order_date;
    }

    public double getTotalCost()
    {
        double result = 0.0;

        return result;
    }
}
Order Class
public class Order
{
    private int order_no;
    private double total_cost;
    private LocalDate order_date;

    public Order()
    {
    }

    public int getOrderNo()
    {
        return order_no;
    }

    public void setOrderNo(int orderno)
    {
        order_no = orderno;
    }

    public LocalDate getDateCreated()
    {
        return order_date;
    }

    public void setDateCreated(LocalDate date)
    {
        order_date = date;
    }

    public void setDateCreated(String date)
    {
        order_date = LocalDate.parse(date);
    }

    public double getTotalCost()
    {
        double result = 0.0;

        return result;
    }
}
Item Class
public class Item
{
    
}
Item Class
public class Item
{
    private double  item_cost;
    private int     quantity;
    private int     unique_id;
    
    public  Item()
    {
    }
    
    public  double  getItemCost()
    {
        return item_cost;
    }
    
    public  int getQuantity()
    {
        return quantity;
    }
    
    public  int getUniqueId()
    {
        return unique_id;
    }
    
    public  double  getTotalCost()
    {
        return quantity * item_cost;
    }

    public void setItem_cost(double item_cost)
    {
        this.item_cost = item_cost;
    }

    public void setQuantity(int quantity)
    {
        this.quantity = quantity;
    }

    public void setUnique_id(int unique_id)
    {
        this.unique_id = unique_id;
    }
}
Product Class
Not available
Product Class
public class Product
{
    private String  description;
    private double  price;
    private String  product_code;
	private int		quantity;

    public  Product()
    {
        
    }
    
    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public double getPrice()
    {
        return price;
    }

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

    public String getProductCode()
    {
        return product_code;
    }

    public void setProductCode(String product_code)
    {
        this.product_code = product_code;
    }

	public	int	getQuantity()
	{
		return this.quantity;
	}

	public	void	setQuantity( int qty )
	{
		this.quantity = qty;
	}
}