Showing posts with label Data Types. Show all posts
Showing posts with label Data Types. Show all posts

Wednesday, October 27, 2010

Parameters


The inputs required by a behavior are often called Parameters and like state, a data type is required in the definition of a parameter.

The format for representing parameters in a behavior:  

BehaviorName(Parameter: DataType)

The format for representing a behavior that has no parameters:  

BehaviorName()

Class example:



The Login behavior of a class called Player class may look like this:

Login(Password: String)
The parenthesis (brackets) which follow the name of the behavior are used to identify any parameters that are required for the behavior to function. In this case of the Login behavior, a parameter called Password which has a data type of String is required by the behavior for it to function. In other words, the Player class has a Login function but it needs a String password to execute.

The Logout behavior of the Player class looks like this:

Logout()

You will notice that the parenthesis for this behavior are empty. This behavior does not require any parameters to execute.

There are two behaviors in the Player class which are responsible for increasing and decreasing the Player class Health state:
IncreaseHealth(Increase: Integer)
DecreaseHealth(Decrease: Integer)

Both of these behaviors require an Integer (whole number) parameter. In other words, these behaviors need to know how much to increase or decrease the Player Health state. As you might imagine, a Player may incur varying amounts of damage or gain varying amounts of health depending on the various interactions within game play.

What is Date?

The Date data type is used to represent dates ranging from January 1 of the year 0001 through December 31 of the year 9999, and times from 12:00:00 AM (midnight) through 11:59:59.9999999 PM.

What is Decimal?

The Decimal data type is used to store currency and other decimal values as it supports up to 28 digits to the right of the decimal point.

What is Boolean?

 The Boolean data type is a simple True/False type.

What is an Integer?

 The Integer data type is a numeric type and can hold whole numbers - such as 1, 100, 3500.

What is a String?


The String data type can hold any combination of keyboard characters - this means letters, numbers and special characters.

Words and Text: Using String Variables to Organize Words

From http://msdn.microsoft.com/en-au/library/whhs118y.aspx

"In this lesson, you will learn how to use the String data type to represent words and text.
The previous lesson showed how to use variables to store data in a program, and that each variable must be of the appropriate type for the data that it will store. In this lesson, you will learn more about the String data type, which is used to store text." Read more >>>

Variables

A variable is a value that can change. For instance, weather forecasters often refer to variable winds and variable temperatures - meaning that the wind and temperature could change without warning. In the context of computers, however, variables only change when told to and cannot do anything on their own.

Variables must be declared before they are used in Visual Basic.NET. To declare a new variable, you must use the Dim keyword, which is short for "dimension", referring to the process of reserving memory for the new variable.

You can create any variable you need using Dim. When you hear the word "variable', just remember that it is just a pointer to a location in memory in which some data is stored.

Variables may be used in many different situations such as storing a username, storing numbers for calculation, storing a weather temperature etc.

A declaration statement is used to declare the existence of the variable. It is defined as a particular data type. It may then be assigned a value.

Syntax
Dim VariableName As DataType

Code eg: Declaring a variable.
In this case, the variable is a String data type called strUserFirstName with a value of Straximo 
 
Dim strUserFirstName As String = "Straximo"

Data Type Summary (Visual Basic)

http://msdn.microsoft.com/en-us/library/47zceaw7%28v=VS.90%29.aspx

Saturday, October 9, 2010

Data types in Microsoft Access

From http://www.basenow.com/help/Data_types_in_Microsoft_Access.asp

"The following list summarizes all the field data types available in Microsoft Access, their uses, and their storage sizes..."