Exercises Java with Examples-
Practice Exercises Java 4,5 5 302940

Orders - Practice Exercises Java


Lesson 6:

Object oriented programming


Exercise 6.6:

Orders


Objetive:

Using Visual Studio, create a project and the corresponding classes (using several files) for this classes diagram.

Each class must include the attributes and methods shown in the diagram. Consider that all cardinalities are 1:1.


Source Code:


package Orders;
public class Customer
{
	public Customer()
	{
		name = "";
		address = "";
	}
	protected String name;
	protected String address;
	protected Order[] o;
}

package Orders;
public class Item extends OrderDetail
{
	public Item()
	{
		shippingWeight = "";
		description = "";
	}

	protected String shippingWeight;
	protected String description;

	public final double getPriceForQuantity()
	{
		return 0;
	}

	public final double getWeight()
	{
		return 0;
	}

	public final String GetShippingWeight()
	{
		return shippingWeight;
	}

	public final String GetDescription()
	{
		return description;
	}
	public final void SetShippingWeight(String shippingWeight)
	{
		this.shippingWeight = shippingWeight;
	}

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

package Orders;
public class Order
{
	public Order()
	{
		status = "";
	}
	protected java.time.LocalDateTime date = java.time.LocalDateTime.MIN;
	protected String status;

	protected OrderDetail[] o;

	public final double calcTax()
	{
		return 0;
	}

	public final double calcTotal()
	{
		return 0;
	}
	public final double calcTotalWeight()
	{
		return 0;
	}

	public final java.time.LocalDateTime GetDate()
	{
		return date;
	}

	public final String GetStatus()
	{
		return status;
	}
	public final void SetDate(java.time.LocalDateTime date)
	{
		this.date = date;
	}

	public final void SetStatus(String status)
	{
		this.status = status;
	}
}

package Orders;
public class OrderDetail
{
	public OrderDetail()
	{
		quantity = 0.0;
		taxStatus = "";
	}
	protected Item[] i;
	protected double quantity;
	protected String taxStatus;

	public final double calcSubTotal()
	{
		return 0;
	}

	public final double calcWeight()
	{
		return 0;
	}

}
Exercisey 6.6

Share Now:


Google Ads





Privacy Policy:



Google uses associated advertising companies to serve ads when it visits our website. These companies may use the information they obtain from your visits to this and other websites (not including your name, address, email address, or phone number) to provide you with announcements about products and services that interest you. If you would like to learn more about this practice and know your options to prevent these companies from using this information. Click in... Privacy and Terms of Google.

Cookies

This site uses Google cookies to provide its services, to personalize advertisements and to analyze traffic. Google receives information about your use of this website. More information in... Privacy and Terms of Google.