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—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.

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