Time for action – Setting up the model

First, let's create our computer model.

We need to have the following data about the computers:

  • Their names
  • The operating systems they are running

Note that the OS field will use an enum with the three mainly used OS fields and an "Other" field.

Therefore, let's create our Computer.hx file with the following code in the computerList.models namespace:

package computerList.models;

class Computer
{
   public var name:String;
   public var operatingSystem : OS;
   
   public function new()
   {
      
   }
}

enum OS
{
   Windows;
   Linux(distro:String);
   MacOSX;
   Other(name:String);
}

That is all we to write in our model at the moment.

Get haXe 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.