Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
73
Task/Polymorphism/AutoHotkey/polymorphism.ahk
Normal file
73
Task/Polymorphism/AutoHotkey/polymorphism.ahk
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
MyPoint := new Point(1, 8)
|
||||
MyPoint.Print()
|
||||
MyCircle := new Circle(4, 7, 9)
|
||||
MyCircle2 := MyCircle.Copy()
|
||||
MyCircle.SetX(2) ;Assignment method
|
||||
MyCircle.y := 3 ;Direct assignment
|
||||
MyCircle.Print()
|
||||
MyCircle2.Print()
|
||||
MyCircle.SetX(100), MyCircle.SetY(1000), MyCircle.r := 10000
|
||||
MsgBox, % MyCircle.__Class
|
||||
. "`n`nx:`t" MyCircle.GetX()
|
||||
. "`ny:`t" MyCircle.y
|
||||
. "`nr:`t" MyCircle.GetR()
|
||||
return
|
||||
|
||||
class Point
|
||||
{
|
||||
Copy()
|
||||
{
|
||||
return this.Clone()
|
||||
}
|
||||
GetX()
|
||||
{
|
||||
return this.x
|
||||
}
|
||||
GetY()
|
||||
{
|
||||
return this.y
|
||||
}
|
||||
__New(x, y)
|
||||
{
|
||||
this.x := x
|
||||
this.y := y
|
||||
}
|
||||
Print()
|
||||
{
|
||||
MsgBox, % this.__Class
|
||||
. "`n`nx:`t" this.x
|
||||
. "`ny:`t" this.y
|
||||
}
|
||||
SetX(aValue)
|
||||
{
|
||||
this.x := aValue
|
||||
}
|
||||
SetY(aValue)
|
||||
{
|
||||
this.y := aValue
|
||||
}
|
||||
}
|
||||
|
||||
class Circle extends Point
|
||||
{
|
||||
GetR()
|
||||
{
|
||||
return this.r
|
||||
}
|
||||
__New(x, y, r)
|
||||
{
|
||||
this.r := r
|
||||
base.__New(x, y)
|
||||
}
|
||||
Print()
|
||||
{
|
||||
MsgBox, % this.__Class
|
||||
. "`n`nx:`t" this.x
|
||||
. "`ny:`t" this.y
|
||||
. "`nr:`t" this.r
|
||||
}
|
||||
SetR(aValue)
|
||||
{
|
||||
this.r := aValue
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue