Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Creating Mobile Apps with Appcelerator Titanium

You're reading from   Creating Mobile Apps with Appcelerator Titanium There's no better way to learn Titanium than by using the platform to create apps for iPhone, iPad, and Android, and this tutorial lets you do exactly that. It's a truly hands-on approach that covers all the essential bases.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781849519267
Length 318 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Christian Brousseau Christian Brousseau
Author Profile Icon Christian Brousseau
Christian Brousseau
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Stopwatch (with Lap Counter) FREE CHAPTER 2. Sili, the assistant that just listens 3. The To-do List 4. Interactive E-book for iPad 5. You've Got to Know When to Hold 'em 6. JRPG – Second to Last Fantasy 7. JRPG – Second to Last Fantasy Online 8. Social Networks 9. Marvels of the World around Us 10. Worldwide Marco Polo A. References Index

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 value of zero dollars and zero cents. Notice that those two parameter values are the same information that will be required in the forms when adding a new stock to the portfolio:

function Stock(symbol, quantity) {
  this.symbol = symbol;
  this...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime