A Trypillia package demonstrating Object-Oriented Programming (OOP) concepts using apples. This project provides a simple model of an AppleTree and Apple to showcase how namespaces, classes, instantiation, and lists work in Trypillia.
- Apple: Represents an individual apple with properties like variety, color, weight, and an action to
eat(). - AppleTree: Represents a tree that can grow new apples (
growApple()), keep track of them, and harvest them (harvest()).
Use the Trypillia Package Manager (TrypPM) to install this package in your project. Add it to your tryp.json:
{
"dependencies": {
"github:ChernegaSergiy/apples": "1.0.0"
}
}Then run:
tryppm installAfter installation, load the auto-generated autoloader and use the classes in your Trypillia script (e.g., main.try):
load "tryp_modules/autoload.try";
use Apples.Models.AppleTree;
let tree = AppleTree("Gala");
tree.growApple("red", 150);
tree.growApple("yellowish-red", 160);
print("The tree has " + tree.getApplesCount() + " apples.");
let basket = tree.harvest();
for (let i = 0; i < List.length(basket); i = i + 1) {
let apple = basket[i];
apple.eat();
}
Contributions are welcome and appreciated! Here's how you can contribute:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
This project is licensed under the CSSM Unlimited License v2.0 (CSSM-ULv2). See the LICENSE file for details.