new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 deletions
22
Task/Classes/Tcl/classes.tcl
Normal file
22
Task/Classes/Tcl/classes.tcl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package require TclOO
|
||||
oo::class create summation {
|
||||
variable v
|
||||
constructor {} {
|
||||
set v 0
|
||||
}
|
||||
method add x {
|
||||
incr v $x
|
||||
}
|
||||
method value {} {
|
||||
return $v
|
||||
}
|
||||
destructor {
|
||||
puts "Ended with value $v"
|
||||
}
|
||||
}
|
||||
set sum [summation new]
|
||||
puts "Start with [$sum value]"
|
||||
for {set i 1} {$i <= 10} {incr i} {
|
||||
puts "Add $i to get [$sum add $i]"
|
||||
}
|
||||
$sum destroy
|
||||
Loading…
Add table
Add a link
Reference in a new issue