如何在此程序中添加入口点,以便程序运行

时间:2019-05-15 17:15:16

标签: functional-programming f#

我如何拥有价值观,例如在代码余额中保留5英镑,以便程序运行

type Account = 

    {accountNumber:string; mutable balance:float} 

    member this.Withdraw(cash:float) = 
        if cash > this.balance then
            Console.WriteLine("Insufficient Funds. The Amount you wish to withdraw is greater than your current account balance.")
        else
            this.balance <- this.balance - cash
            Console.WriteLine("You have withdrawn £" + cash.ToString() + ". Your balance is now: £" + this.balance.ToString())

    member this.Deposit(cash:float) =
        this.balance <- this.balance + cash
        Console.WriteLine("£" + cash.ToString() + " Cash Deposited. Your new Balance is: £" + this.balance.ToString())

    member this.Print() = 
        Console.WriteLine("Account Number: " + this.accountNumber)
        Console.WriteLine("Balance: £" + this.balance.ToString())

警告FS0988:程序主模块为空:运行时将不会发生任何事情

我试图输入以下代码:

let accountNumber = 123
let balance = 5

但仍然没有任何反应

0 个答案:

没有答案