1. Create a Class to contain a Client order 2. Create attributes of that class t
ID: 3663724 • Letter: 1
Question
1. Create a Class to contain a Client order
2. Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes.
3. Create a class constructor without parameters that initializes the attributes to default values.
4. Create a class constructor with parameters that initializes the attributes to the passed in parameter values.
5. Create a behavior of that class to generate a welcome message that includes the company name.
6. Create a Class to contain a Client order detail row
7. Create attributes of that class to store Product Name, Price and Amount. Create a public property for each of these attributes.
8. Create a constructor without parameters that set all the attributes to an empty string or zero.
9. Create a constructor with parameters that sets all the attributes to the passed in parameters.
10. Create a behavior that, when provided a sales tax value, returns the total price for a detail row including sales tax.
11. Create a behavior that, when provided a product name, price and quantity, returns a single line order detail.
Explanation / Answer
clientOrder.java
public class ClientOrder{
public String companyName;
public String address;
public double salesTax;
public ClientOrder(){
companyName = "";
address = "";
salesTax = 0;
}
public ClientOrder(String c, String a, double s){
companyName = c;
address = a;
salesTax = s;
}
public void welcome(){
System.out.println("Hi! Welcome to " + companyName);
}
}
// clientOrderDetail.java
public class ClientorderDetail{
public String productName;
public double price;
public int amount;
public ClientorderDetail(){
productName = "";
price = 0;
amount = 0;
}
public ClientorderDetail(String p, double pr, int a){
productName = p;
price = pr;
amount = a;
}
public double totalPrice(double salesTax){
return amount + salesTax;
}
public ClientorderDetail lineOrderDetail(String p, double pr, int a){
return new ClientorderDetail(p, pr, a);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.