Share on Google+Share on Google+

arvind
restrictedproduct
0 Answer(s)      6 years and a month 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









Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads