Example #1
0
    /**
     * Creates a standard arrangement for the vending machine. All the
     * components are created and interconnected. The hardware is initially
     * empty. The product kind names and costs are initialized to " "
     * and 1 respectively.
     *
     * @param coinKinds
     *            The values (in cents) of each kind of coin. The order of the
     *            kinds is maintained. One coin rack is produced for each kind.
     *            Each kind must have a unique, positive value.
     * @param selectionButtonCount
     *            The number of selection buttons on the machine. Must be
     *            positive.
     * @param coinRackCapacity
     *            The maximum capacity of each coin rack in the machine. Must be
     *            positive.
     * @param productRackCapacity
     *            The maximum capacity of each product rack in the machine. Must
     *            be positive.
     * @param receptacleCapacity
     *            The maximum capacity of the coin receptacle, storage bin, and
     *            delivery chute. Must be positive.
     * @throws IllegalArgumentException
     *             If any of the arguments is null, or the size of productCosts
     *             and productNames differ.
     */
    public VendingMachine(Cents[] coinKinds, int selectionButtonCount, int coinRackCapacity, int productRackCapacity, int receptacleCapacity)
    {
        this.hardwareFacade = new HardwareFacade(coinKinds, selectionButtonCount, coinRackCapacity, productRackCapacity, receptacleCapacity);

        this.paymentFacade = new PaymentFacade(this.hardwareFacade);
        this.commFacade    = new CommsFacade(this.hardwareFacade);
        this.productFacade = new ProductFacade(this.hardwareFacade);
        this.businessRule  = new BusinessRule(this.paymentFacade, this.productFacade, this.commFacade);
        /* YOU CAN BUILD AND INSTALL THE HARDWARE HERE */
    }
Example #2
0
    /**
     * Creates a standard arrangement for the vending machine. All the
     * components are created and interconnected. The hardware is initially
     * empty. The product kind names and costs are initialized to " "
     * and 1 respectively.
     *
     * @param coinKinds
     *            The values (in cents) of each kind of coin. The order of the
     *            kinds is maintained. One coin rack is produced for each kind.
     *            Each kind must have a unique, positive value.
     * @param selectionButtonCount
     *            The number of selection buttons on the machine. Must be
     *            positive.
     * @param coinRackCapacity
     *            The maximum capacity of each coin rack in the machine. Must be
     *            positive.
     * @param productRackCapacity
     *            The maximum capacity of each product rack in the machine. Must
     *            be positive.
     * @param receptacleCapacity
     *            The maximum capacity of the coin receptacle, storage bin, and
     *            delivery chute. Must be positive.
     * @throws IllegalArgumentException
     *             If any of the arguments is null, or the size of productCosts
     *             and productNames differ.
     */
    public VendingMachine(Cents[] coinKinds, int selectionButtonCount, int coinRackCapacity, int productRackCapacity, int receptacleCapacity)
    {
        this.hardwareFacade = new HardwareFacade(coinKinds, selectionButtonCount, coinRackCapacity, productRackCapacity, receptacleCapacity);

        CommunicationFacade cf  = new CommunicationFacade(this.hardwareFacade);
        ProductFacade       prf = new ProductFacade(this.hardwareFacade);
        PaymentFacade       paf = new PaymentFacade(this.hardwareFacade);

        BuisnessRule br = new BuisnessRule(cf, prf, paf);
    }
        public InvoiceController()
        {
            DataContext Context = DataContext.getInstance();

            salesFacade       = new SalesOrderFacade(Context);
            salesDetailFacade = new SalesOrderDetailsFacade(Context);
            payFacade         = new PaymentFacade(Context);
            wareHouseFacade   = new WareHouseFacade(Context);
            pWMFacade         = new PWMFacade(Context);
            productsFacade    = new ProductsFacade(Context);
        }
        public HomeController()
        {
            DataContext Context = DataContext.getInstance();

            userFacade      = new UserFacade(Context);
            userlogin       = new UserLoginFacade(Context);
            wareHouseFacade = new WareHouseFacade(Context);
            productsFacade  = new ProductsFacade(Context);
            sessionContext  = new SessionContext();
            paymentFacade   = new PaymentFacade(Context);
        }
Example #5
0
        static void Main(string[] args)
        {
            PaymentFacade paymentFacade = new PaymentFacade();
            CreditCard    creditCard    = new CreditCard();

            paymentFacade.PayForAll(creditCard, 270, 325, 75);
            paymentFacade.PayForHomeAndCredit(creditCard, 270, 325);
            paymentFacade.PayForHomeAndUniversity(creditCard, 270, 75);
            paymentFacade.PayForCreditAndUniversity(creditCard, 325, 75);

            Console.ReadKey();
        }
Example #6
0
        static void Main(string[] args)
        {
            var paymentMachineService = new PaymentMachineService("Stone");
            var creditCardService     = new CreditCardService("Visa");

            var paymentFacade = new PaymentFacade(paymentMachineService, creditCardService);

            var response = paymentFacade.DoPayment(1000);

            Console.WriteLine(response);
            Console.ReadKey();
        }
Example #7
0
    public BuisnessRule(CommunicationFacade cf, ProductFacade prf, PaymentFacade paf)
    {
        this.cf  = cf;
        this.prf = prf;
        this.paf = paf;

        this.cf.SelectionMade += new EventHandler(SelectionMade);
        this.cf.ProductVended += new EventHandler(productVendedHandler);
        this.cf.OutOfStock    += new EventHandler(outOfStockHandler);

        this.paf.FundsSufficient   += new EventHandler(ReturnToDelivery);
        this.paf.FundsInsufficient += new EventHandler(FundsInsufficiantHandler);
    }
    // This class talks to the facades
    public BusinessLogic(HardwareFacade hardwareFacade)
    {
        // Create Facades and pass the hardware facade to them so that they can subscribe to appropriate events
        this.payment = new PaymentFacade(hardwareFacade);
        this.comms   = new CommunicationFacade(hardwareFacade);
        this.prod    = new ProductFacade(hardwareFacade);

        // Detect if a selection was made
        this.comms.SelectionMade += new EventHandler <SelectionEventArgs>(initiate);

        // Detect errors from payment and product and pass it to the comms facade
        this.payment.error += new EventHandler <ErrorEventArgs>(sendError);
        this.prod.error    += new EventHandler <ErrorEventArgs>(sendError);
    }
Example #9
0
        public ActionResult Client(string ReqNo)
        {
            var comid = db.UserProfiles.Where(u => u.UserName == User.Identity.Name).Select(s => s.CompanyID).First();

            ViewData["Company"]   = db.Companies.Where(c => c.CompanyID == comid).Select(n => n.CompanyName).First().ToString();
            ViewData["CompanyID"] = comid;

            int     Req     = Convert.ToInt16(ReqNo);
            decimal PassTot = PaymentFacade.GetPassTotal(Req);

            ViewBag.Total = PassTot;
            ViewBag.ReqNo = ReqNo;

            return(View());
        }
 public PaymentController()
 {
     _bookingFacade = new BookingFacade();
     _menuFacade    = new MenuFacade();
     _paymentFacade = new PaymentFacade();
 }
Example #11
0
 public PaymentFacadeTest()
 {
     paymentComponentMock = new Mock <IPaymentComponent>();
     paymentFacade        = new PaymentFacade(paymentComponentMock.Object);
 }