我的程序正在给我警告(程序的主要模块是空的:运行时什么都不会发生(,这与我需要放置存款成员的事实有关在撤回会员之前(因为程序中没有任何内容(
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())
该程序应定义一个f#类型命名帐户,该帐户包含帐户(字符串(和余额(float(字段。该类型应包括将资金撤回并将货币存入帐户的方法以及在控制台内的单个线上显示字段值的打印成员。如果提款金额大于帐户余额,则应取消交易并显示合适的消息。
在任何编程语言中几乎所有程序都需要一个入口点。这是F#中的main
的文档。
大多数裸露的F#程序将以main
函数的形式开始,该功能看起来像这样:
[<EntryPoint>]
let main args =
printfn "Arguments passed to function : %A" args
// Return 0. This indicates success.
0
您需要将自己的逻辑放在main
中。