O'Reilly logo

Creating Mobile Apps with Appcelerator Titanium by Christian Brousseau

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

Moving stocks around

In order to have a clear understanding of how we will manage our stocks, we must first define what exactly constitutes a stock in our application. For our needs, a stock must have the following attributes:

  • Its symbol, in order to distinguish it from the others
  • Its price on the stock market
  • How much of this stock do we own? (quantity)

Now, we need to represent the model in the code that is easy to handle. For this, we will create a new file called Stock.js and it will be located in the Resources/model directory.

Inside this new file, we will create a new function called Stock with two parameters. Inside the function, we assign the symbol and quantity attributes with the values passed as parameters. We will set the price to its default ...

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