More Objects

Home/Getting started/More Objects
More Objects 2016-12-23T09:03:24+00:00

The Maths Class

Introduction

You have already met a number of Small Basic Objects – elements within your programming language that package up related methods, properties and other features to help you program.  There are many other ‘objects’ available to you and this Topic is about introducing you to some that you will find both useful and interesting.

The Maths Class

The Maths class gives us access to mathematical functions that calculate or ‘return’ some very useful values for use to use in our programs.  Full blown programming languages usually provide many hundreds of maths functions to perform the most complex calculations but Small Basic has tried to reduce this to a manageable list of really useful ones for you.  Most take one or two numbers as ‘parameters‘ and return a result having performed the required calculation.

End of Topic Tasks

Maths Methods

Orange CubeProperties

There is only one property for the Math Class and this is a special one in that it is read-only.  I.e.  you cannot change it.  It is the value of Pi.  Math.Pi always contains the value of Pi – 3.14159265358979

Red Cube

Functions
The available Maths Functions can be viewed here.  They are referred to as functions as this object is just a ‘class’ – you can’t place a Maths object in your programs – you just make use of its features.

The Clock Class

The Clock Class

The Clock class gives us access to your computers system clock.  Don’t be misled by the name, however, as this class also provides access to date information as well.  As computers work so quickly, the clock can not only tell you the hour, minute or second of the day, it ca also tell you the millisecond – 1000th of a second.  Using the clock not only tells you the time but also enables you to time your programs or how long it takes for a user to respond to a prompt.

End of Topic Tasks

Clock Properties

Orange Cube

Properties
 These are the properties of the Clock object.  Using this object will enable you to include references to the date and time in your programs.

The Sound Class

The Sound Class

The Sound class gives us access to sounds and sound effects for your programs.  It can be used to provide simple audio feedback or just interest (or annoyance) for your end users.  Later I will be introducing an extension object that adds speech capabilities to your programs.  This would, for example, enable you to make a speaking clock program.

End of Topic Tasks

Sound Methods

Red Cube

Methods
These are the Methods available with the Sound object.  Using sounds can add interest and fun to you programs.

Purple Cube

Information
The PlayMusic() method available with Sound class requires the ‘music’ to be supplied as a string – this information pop-up provides you with the required information.