Skip to content

ChernegaSergiy/apples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apples

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.

Features

  • 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()).

Installation

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 install

Usage

After 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();
}

Contributing

Contributions are welcome and appreciated! Here's how you can contribute:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and adhere to the existing coding style.

License

This project is licensed under the CSSM Unlimited License v2.0 (CSSM-ULv2). See the LICENSE file for details.

About

A Trypillia package that demonstrates object-oriented programming with a model of apple trees and their fruits.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors