Skip to content

Commit

Permalink
Add AutoHotkey sample file
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgriv committed Jul 26, 2024
1 parent 694050d commit 00b51e6
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions samples/dark_castle.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* In a realm cloaked in shadows...
*/

class Castle {
; Class properties
name := ""
constructionYear := 0
destructionYear := 0
features := []

; Constructor
__New(name, constructionYear, destructionYear, features*) {
this.name := name
this.constructionYear := constructionYear
this.destructionYear := destructionYear
this.features := features
}

; Method to calculate the age of the castle
getAge() {
return this.calcAge()
}

; Private method to calculate the age
calcAge() {
return this.destructionYear - this.constructionYear
}

; Method to get the name of the castle
getName() {
return this.name
}

; Method to get the features of the castle
getFeatures() {
return this.features
}
}

; ...there existed a Dark Castle

; Main script
castle := new Castle("Moonshadow Fortress", 980, 1503, "Eerie Glow", "High Battlements")

; Using the 'castle' object and displaying details
MsgBox, Castle Name: % castle.getName()
MsgBox, Castle Age: % castle.getAge() " years"
MsgBox, Castle Features:
for feature in castle.getFeatures() {
MsgBox, - %feature%
}

; Hotkey to display castle details
^!c::
MsgBox, Castle Name: % castle.getName()
MsgBox, Castle Age: % castle.getAge() " years"
MsgBox, Castle Features:
for feature in castle.getFeatures() {
MsgBox, - %feature%
}
return

; Function to display a welcome message
WelcomeMessage() {
MsgBox, Welcome to the Moonshadow Fortress!
}

; Call the function
WelcomeMessage()

0 comments on commit 00b51e6

Please sign in to comment.