Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
28
Task/Classes/Ballerina/classes.ballerina
Normal file
28
Task/Classes/Ballerina/classes.ballerina
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import ballerina/io;
|
||||
|
||||
class Dog {
|
||||
string name; // field
|
||||
|
||||
// Initializes a Dog instance passing it a name
|
||||
// which is stored in the 'name' field.
|
||||
function init(string name) {
|
||||
self.name = name;
|
||||
}
|
||||
|
||||
// Function to make a noise.
|
||||
function makeNoise() {
|
||||
io:println("Woof!");
|
||||
}
|
||||
}
|
||||
|
||||
public function main() {
|
||||
// Create a new Dog instance and assign a reference to it
|
||||
// to the variable b.
|
||||
Dog d = new Dog("Rover");
|
||||
|
||||
// Print the dog's name.
|
||||
io:println("The dog is called ", d.name);
|
||||
|
||||
// Make a noise.
|
||||
d.makeNoise();
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
(define (make-account balance)
|
||||
(define (withdraw amount)
|
||||
(if (>= balance amount)
|
||||
(begin (set! balance (- balance amount))
|
||||
|
|
@ -12,3 +13,13 @@
|
|||
(else (error "Unknown request -- MAKE-ACCOUNT"
|
||||
m))))
|
||||
dispatch)
|
||||
|
||||
(define acc (make-account 100))
|
||||
((acc 'withdraw) 50)
|
||||
50
|
||||
((acc 'withdraw) 60)
|
||||
"Insufficient funds"
|
||||
((acc 'deposit) 40)
|
||||
90
|
||||
((acc 'withdraw) 60)
|
||||
30
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue