restrictedproduct

Ads

 
 
 

Share on Google+Share on Google+

arvind
restrictedproduct
0 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners
<p>import java.util.*; //Use of ArrayList
import java.io.*; //Use of InputStreamReader and BufferedReader
import java.util.regex.*; //Use of regular expressions
import java.text.*;</p>

<p>class ProductController
{
  OrderController orderControllerOb=new OrderController();</p>

<p>  public void initiateReportOnProductsManufactured()
   {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     OrderUI orderUI=new OrderUI();
     ProductUI productUI=new ProductUI();
     Order orderOb=null;
     ArrayList&lt;Object> orderDetails=new ArrayList&lt;Object>();
     int orderId=orderUI.getOrderId();
     if(orderId!=-1) //If system error occurs
     {
      orderOb=CDAManufacturers.searchOrderList(orderId); //Check order id is in the order list
      if(orderOb!=null) //If order id is in the order list
      {
        orderDetails=CDAManufacturers.returnOrderDetails(orderOb); //Fetch order details from the order list
        productUI.displayOrderDetails(orderDetails); //Display order details
        orderUI.displayMenu(); //clerk's menu is displayed
      }
      else
      {
        orderUI.displayErrorMessage("Invalid order ID!!!!");
        orderUI.displayMenu(); //clerk's menu is displayed
      }
    }
    else
    {
      orderUI.displayErrorMessage("Sorry!!! unable to display the order details");
      orderUI.displayMenu(); //clerk's menu is displayed
    }
  }
  public void initiateReportOnTaxCollected()
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    OrderUI orderUI=new OrderUI();
    Order orderOb=null;
    double bill=0.0,salesTax=0.0,octroi=0.0,customsDuty=0.0;
    ArrayList&lt;Object> orderDetails=new ArrayList&lt;Object>();
    int orderId=orderUI.getOrderId();
    if(orderId!=-1) //If system error occurs
    {
      orderOb=CDAManufacturers.searchOrderList(orderId); //Check order id is in the order list
      if(orderOb!=null) //If order id is in the order list
      {
        orderDetails=CDAManufacturers.returnOrderDetailsForBill(orderOb); //Fetch order details from the order list
        bill=CDAManufacturers.calculateBill(orderDetails);
        salesTax=0.1*bill;
        octroi=0.14*bill;
        customsDuty=0.16*bill;
        System.out.println("Rs."+salesTax);
        System.out.println("Rs."+octroi);
        System.out.println("Rs."+customsDuty);
        orderUI.displayMenu(); //clerk's menu is displayed
      }
      else
      {
        orderUI.displayErrorMessage("Invalid order ID!!!!");
        orderUI.displayMenu(); //clerk's menu is displayed
      }
    }
    else
    {
      orderUI.displayErrorMessage("Sorry!!! unable to display the order details");
      orderUI.displayMenu(); //clerk's menu is displayed
    }
  }</p>

<p>public void initiateReportOnRevenueEarned()
  { <br />
  orderControllerOb.initiateViewBills();
  }
public void initiateReportOnProductsReturned()
  {
  }
  public void initiateViewSalesOfProducts()
  {
    ProductUI productUiOb=new ProductUI(); //Create ProductUI
    ArrayList&lt;Product> productList=new ArrayList&lt;Product>();
      productList=CDAManufacturers.returnSalesOfProducts(); //Returns list of sales of Products
      productUiOb.viewProductSalesList(productList); //Displays list of sales of Products
    }
  }</p>

<p>//---------------------------------------------------------------------------------</p>

<p>class ProductUI
{
  private InputStreamReader input=new InputStreamReader(System.in);
  private BufferedReader br=new BufferedReader(input);</p>

<p>  //Contract: ProductSalesList(List):void
  //Displays product id, product name and sales count of the product for given product list
  public void viewProductSalesList(ArrayList&lt;Product> productList)
  {
    System.out.println(" Product\t\t------------Sales-----------");
    System.out.println("");
    for(Product productOb:productList)
      System.out.println(productOb.getProductName()+"\t\t\t\t"+productOb.getProductSalesCount());
    displayMenu(); //Display administrator's menu
  }</p>

<p>  //Contract: displayErrorMessage(String):void
  //Displays error message and then the administrator's menu
  public void displayErrorMessage(String msg)
  {
    System.out.println(msg);
    displayMenu(); //Display administrator's menu
  }</p>

<p>  //Contract: displayMenu():void
  //Displays administrator's menu
  public void displayMenu()
  {
    try
    {
      System.out.println("");
      System.out.println("Press any key to continue");
      br.readLine();
      MainClerkSystem mainclerkSystemOb=new MainClerkSystem();
      mainclerkSystemOb.initiateClerkView();
    }
    catch(Exception e)
    {
      System.err.println("Exception: "+e);
    }
  } </p>

<p>  //Contract: requestProductDetailsConfirmation():String
  //Reads the product details and validates them
  private String requestProductDetailsConfirmation()
  {
    String cont="";
    boolean flag=false;
    try
    {
      while(flag==false)
      {
        System.out.println("");
        System.out.println("Are you sure you want to add product? (Y/N): ");
        cont=br.readLine();
        if(cont.equalsIgnoreCase("y")||cont.equalsIgnoreCase("n"))
          flag=true;
        else
          System.out.println("Please enter Y or N...");
      }
      return(cont);
    }
    catch(Exception e)
    {
      //System.err.println("Exception: "+e);
      return("n");
    }
  }</p>

<p>  //Contract: notifyProductAdditionSuccess(Object):void
  //Prompt product's successfully addition and display its id
  public void notifyProductAdditionSuccess(Product productOb)
  {
      displayMenu();
  }</p>

<p>  //Contract:displayOrderDetails(List):void
  //Displays the order details which is passed as a list
  public void displayOrderDetails(ArrayList&lt;Object> orderDetails)
  {
    System.out.println("");
    System.out.println("Date Of Order :\t"+orderDetails.get(3));
    int x=((orderDetails.size()-4)/2);
    System.out.println("");
    System.out.println("Quantity Manufactured \t Products Name");
    for(int i=5;i<orderDetails.size()-x;i++)
    {
      System.out.println("\t"+orderDetails.get(i+x)+"\t\t"+orderDetails.get(i));
    }
  } <br />
}</p>

<p>//----------------------------------------------------------------------------------------</p>

<p>//Class Product:
//Attributes: int id ; String name ; int quantity ; double price ; int salesCount
//Methods:    setProductId(List):void ; getProductId():list ; setProductName(String):void ; getProductName():String
//            setProductQuantity(String):void ; getProductQuantity():int ; setProductPrice(double):void 
//            getProductPrice():double ; setProductSalesCount(int):void ; getProductSalesCount():int
class Product
{
  private int id;
  private String name;
  private int quantity;
  private double price;
  private int salesCount;</p>

<p>  //Contract: setProductId(int):void
  //It modifies Product id
  public void setProductId(int id)
  {
    this.id=id;
  }</p>

<p>  //Contract: getProductId():int
  //It returns Product id
  public int getProductId()
  {
    return(id);
  }
  //Contract: setProductName(String):void
  //It modifies product name
  public void setProductName(String name)
  {
    this.name=name;
  }</p>

<p>  //Contract:getProductName():String
  //It returns product name
  public String getProductName()
  {
    return(name);
  }</p>

<p>  //Contract: setProductQuantity(String):void
  //It modifies product name
  public void setProductQuantity(int quantity)
  {
    this.quantity=quantity;
  }</p>

<p>  //Contract:getProductQuantity():int
  //It returns product name
  public int getProductQuantity()
  {
    return(quantity);
  }
  //Contract: setProductPrice(double):void
  //It modifies product price
  public void setProductPrice(double price)
  {
    this.price=price;
  }</p>

<p>  //Contract:getProductPrice():double
  //It returns product price
  public double getProductPrice()
  {
    return(price);
  }</p>

<p>  //Contract: setProductSalesCount(int):void
  //It modifies product sales count
  public void setProductSalesCount(int salesCount)
  {
    this.salesCount=salesCount;
  }</p>

<p>  //Contract:getProductSalesCount():int
  //It returns product sales count
  public int getProductSalesCount()
  {
    return(salesCount);
  }
}</p>
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java

Ads

 
Advertisement null

Ads