Visual F# 100 Examples: Example Number 7

So far I have been sharing to you guys some examples of Window Based application in Visual F#. This time, for variation sake lets make some console application:

Problem: Make a simple console application mind reader game.
open System
//change the title to Simple Mind Reader Game
System.Console.Title<-"Simple Mind Reader Game"
//change the foreground color to cyan
Console.ForegroundColor<-ConsoleColor.Cyan
//dislay the game title screen
printfn "\t\t\t Mind Reader Game"
printfn "\t\t\tPress enter to continue..."
//waits for a keypress from the user
System.Console.ReadLine()|>ignore
System.Console.Clear()
//the following does the game action sequence
printfn "\t\t\t Think of a five-digit number that has five unique numbers(Eg. 12345)"
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\t Reverse the numbers then subtract the smaller number from the larger number(Eg.54321- 12345)"
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\t Add 10000 to the difference"
printfn "\t\t\t Press enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\tVisualize the sum while I try to read your mind."
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\tThe sum is…"
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\tThe sum is…"
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\tThe sum is…"
printfn "\t\t\tPress enter to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()

printfn "\t\t\t51976"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.