Book Image

haXe 2 Beginner's Guide

5 (1)
Book Image

haXe 2 Beginner's Guide

5 (1)

Overview of this book

Table of Contents (21 chapters)
haxe 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.