Exemplo n.º 1
0
 public bool Transfer(Account source, Account destination, int amount)
 {
     if (amount < 0)
       return false;
      source.Balance -= amount;
      destination.Balance += amount;
      return true;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Calculator.Calculator c = new Calculator.Calculator();
            int i = 5, j = 6;
            c.Swap(ref i, ref j);

            Console.WriteLine(i + " " + j);
            Console.Read();
            Account acc1 = new Account();
            acc1.Balance = 500;
            Account acc2 = new Account();
            acc2.Balance = 300;
            AccountManager manager = new AccountManager();
            manager.Transfer(acc1, acc2, 100);

            /*
            Calculator.Calculator calculatorInstance = new TestApplication.Calculator.Calculator();
            calculatorInstance.Div(false, 2, 4096, "baba", "3", new Calculator.Calculator());
            //TestFalse(false);
            //TestTrue(true);
            Random r = new Random();
            for (int i = 0; i < 100; i++)
            {
                //Test(r.Next() % 2 == 0);
            }

            MsContractsCalculator cc = new MsContractsCalculator();
            //cc.Div(DateTime.Now.Second, 2);

            LinFuCalculator calculator = new LinFuCalculator();

            AdHocContract contract = new AdHocContract();
              //  contract.Preconditions.Add(new LinFuCalculatorPC());
            contract.Postconditions.Add(new AccountPC());
            ProxyFactory factory = new ProxyFactory();

            ContractChecker checker = new ContractChecker(contract);
            checker.Target = new Account();

            ICalculator wrapped = factory.CreateProxy<LinFuCalculator>(checker);
            Account account = factory.CreateProxy<Account>(checker);
            account.Deposit(200);

            // Require.On(contract).ForMethodWith(t => t.Name == "Mult").That<int>(arg => arg != 0).OtherwisePrint("Error");

            WrappedWorker worker = new WrappedWorker(new Worker());
            Worker wrappedWorker = factory.CreateProxy<Worker>(worker);
            wrappedWorker.Do();
            */
        }