O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Managing a fridge

We are going to create software to manage a fridge. We want to be able to add meals inside it, and to list what is in it. Ok, let's start!

  1. Create a folder that is going to hold your project's files.
  2. Create two folders inside it: a src folder and a bin folder.
  3. In your src folder, create a MyFridge folder. This way, we now have a MyFridge package.
  4. In the MyFridge package, create a Fridge.hx file with the following code inside it:
    package MyFridge;
    class Fridge
    {
    public static var meals = new List<Meals>();
    }
    
  5. This way, our fridge will hold a list of meals inside it. We can make this variable static because we will only have one fridge.
  6. Now, in the MyFridge package, create a file named Meal.hx and write the following code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required