Tuesday, October 12, 2010

Creating a database and Designing a database

Create a Database Activity:



Designing a Database Activity:

Monday, October 11, 2010

Database Blog Task

1. What does a column in a table represent?
Field

2. What does a row in a table represent?
Record

3. What does DBMS stand for?
Database Management System

4. What is a primary key in a table used for?
A unique field used to create relationships between different tables.

5. Why is the ID column such a useful field?
Its useful for uniquely identifying records, especially those that share similar details such as a first name and last name.

6. What Access data type would you use to store the string “18 Segway Drive, Moonville” ?
Text

7. What Access data type would you use to record True/False values?
Boolean

8. What Access data type would you use to store a number?
Number

9. What Access data type would you use to store a long string such as an essay or report?
Memo


10. A database is a collection of what?

Tables

11. A table is made up of what?
Records

12. What is a record?
A row of information in a table such as first name, last name and various other information such as telephone numbers, address etc.

13. Are spaces allowed in field names?
No.

Monday, October 4, 2010

File Handling in VB.NET

1. Which of the following methods can be used to open a sequential access file?
AppendText(), CreateText() and OpenText().

2. Which of the following writes the contents of the favouriteTuneTextBox’s Text property, followed by the newline character, to the sequential access file associated with the outFile variable?
outFile.WriteLine(favouriteTuneTextBox.Text)

3. What does IO in the syntax stand for?
Input/Output

4. Which of the following procedures can be used to read information from a sequential access file?
OpenText()

5. Which of the following reads a line of text from the file associated with the inFile variable and assigns the line of text (excluding the newline character) to the msg variable?
msg = inFile.ReadLine()

6. Write the statement required to close the file associated with the inFile variable.
inFile.Close()

7. If a sequential access file contains another character to read, what does the Peek method return?
The Peek method returns the next character if it exists otherwise it returns -1.

8. If a sequential access file does not contain another character to read, what does the Peek method return?
-1

Tuesday, August 17, 2010

Exception hierarchy

1. Find & show the inheritance hierarchy for the above exception types. (Read the documentation at MSDN)

OverflowException:
System.Object
System.Exception
System.SystemException
System.ArithmeticException
System.OverflowException

InvalidCastException:
System.Object
System.Exception
System.SystemException
System.InvalidCastException

IndexOutOfRangeException:
System.Object
System.Exception
System.SystemException
System.IndexOutOfRangeException

NullReferenceException:
System.Object
System.Exception
System.SystemException
System.NullReferenceException

Keyword for throwing an exception

1. Which keyword is used to throw an exception?
"Throw"

2. Looking at the diagram below, discuss the options for exception handling. Should the exception be handled? If so, where should it be handled? Should it be rethrown? Why? Why not?



The exception should be handled on A and should be rethrown at B and C. This is because A is calling B and B is calling C. If C gets an exception, that should be rethrown for B and then B should rethrow it to A so it can be handled properly.

Inheriting the exception class

1. What Visual Basic keyword is used to implement inheritance in a class?
"Inherits"

2. In the event of an exception, what does the Message property of the Exception class contain?
It contains a string that tells the user what the problem is.

Which keyword gives a child class access to all of it’s parent’s public & protected members?
"MyBase"

What is the first statement in a child class constructor?
"MyBase.New(ErrorMessage)"

Monday, August 9, 2010

NullReferenceException Questions

1. What warning does the Visual Studio IDE provide with regards to using variables before they have been assigned a value? What does the warning look like? What does it say?
Variable 'ThisPlayer1' is used before it has been assigned a value. A null reference exception could result at runtime.

2. Post a screen shot of the resulting message box.

OverflowException Questions

1. What is the name of the Visual Basic function (not discussed in this doc, you may like to go back to Automate Processes if you don’t know) we could use to ensure that only numeric data is assigned to the integer variable (therefore avoiding the program crash if non-numeric data is entered)?
IsNumeric()

2. Why does the OverFlowException occur?
It occurs when the value exceeds the limits of the integer data type.
If Below −2,147,483,648
If Above 2,147,483,647

3. What is the range/capacity of an integer?
−2,147,483,648 to 2,147,483,647

4. How would we implement this method? Modify the code to implement the function.
You check to make sure the Integer is not above 2,147,483,647 and is not below −2,147,483,648.

5. Post a screenshot of your code.

InvalidCastException Questions

1. Why does the InvalidCastException occur?
It's trying to set an integer to a value which is a string.

2. What happens if you enter a number within the integer range?
It casts the value correctly and doesn't crash.

3. What is the correct data type to store a string in?
A String

4. What is the correct data type to store a number in?
An Integer

5. Can you store a number in a string variable?
Yes.

IndexOutOfRangeException Questions

1. What is the upperbound of the array?
2

2. How many elements are contained within the array?
3

3. How should this loop be primed? - that is - what do you suggest as a starting value and an ending value?
Starting Value = 0
Ending Value = 2

4. Why does the code in figure 4 produce an IndexOutOfRangeException?
It produces an Exception error because the Ending Value is equal to 3, this is outside the UpperBounds of the array.

5. What value is displayed in the message box when the loop is in it’s second iteration?
"String 2"

6. Post a screen shot of the message box produced in it’s second iteration.

Monday, August 2, 2010

Loop Blog Post 2

1. What is the UpperBound of the array?
2, The UpperBound of the array is the maximum index number (Size of the Array minus one)

2. How many elements are contained in the array?
2, The UpperBound of the array is the maximum index number (Size of the Array minus one)

3. What is the starting index of the array?
0

4. What is the starting value of the loop counter?
0

5. How many times does the loop execute?
3

6. What is the concatenation operator?
"&"

Screenshot:

Loop Blog Post 1

1. What is a Loop Counter?
A loop counter is a looping mechanism available in VB.NET that basically sets a variable to a value and then proceeds to increment a that variable every loop until it reaches the ending condition.

2. How many times does the Loop Execute?
The loop executes 100 times (99 if you only count every time it hits 'Next')

3. What is the final value of the NumberAccumulator variable?
100

Screenshot:

Tuesday, July 27, 2010

Dynamic control forms/objects and more abstract classes

The difference between normal inheritance and abstract inheritance is that an abstract class must be inherited or it could cause compile issues (C++ would have run-time issues) in the program or not function properly as they are built to allow "children" classes to specialize in certain functions.

For example, in a popular game such as Team Fortress, all the player classes have similar traits but some classes can vary such as in Team Fortress 2, a Spy can use a cloak and become invisible or the Scout can double jump. Those traits are specific to that class and cannot be done by any other class. They all have traits in-common though, such as using Health, Weapons, Movement Speed, etc.

Now that I've explained this, time to move onto the difference between Design-Time and Run-Time. I'd prefer to explain this phenomenon as Static Controls/Classes and Dynamic Controls/Classes as Design-Time doesn't technically apply to all languages but only languages that have a Form Designer such as VB.NET.

In any case, the difference between the two is that there are static objects which will always be in the program and there are objects that may or may not be created and deleted "on-the-fly" such as extra form controls (Text Box, Labels, Buttons) and instances of classes. These things can't always be accounted for which is why it is preferred to use Static Classes as much as possible as to not accidentally exceed the RAM limit at Run-Time or cause Memory leaks (which I think VB.NET handles by itself anyway)

In any case, that's all I have to say for now, till next time :D

Friday, July 23, 2010

The Console Program



If you don't know me at all in the "real world" then you probably don't know that I built a PC for the sole purpose of running emulated roms played via Xbox 360 wireless controls. For this to not require a mouse/keyboard, I decided to code my own application to launch the emulators/roms via the Xbox 360 controller.

Originally the application was written in Game Maker 6.1 but unfortunately it caused the N64 emulator to lag and not get enough CPU, so I rewrote it (very quickly) in C++. Fast forward a year, to now and I'm recoding it from scratch as the old version was written with my OLD game engine, both of which were horribly annotated and hard to read.

Whilst there is no aesthetic changes, the performance should be better, and dynamic array crashes shouldn't occur anymore. I also know how to work with the WinAPI much better so a lot of redundant code was removed :)

Monday, July 19, 2010

Abstract Classes

Abstract classes are created when two or more classes share the same states and behaviors. By creating a parent class once with all the necessary states and functions it saves having to double up code which saves time and RAM usage.

Abstract classes are also never instantiated on their own and are only used to help the child/specialized classes.

An example of an abstract class is a group of students at a school. They all have names, a student ID, a house group and a list of classes but some students have a few other qualities such as skills in sports, IT or be part of a school club, these are some things the other students may not have so its specific to a selected few.

Saturday, July 3, 2010

Map Editor, Rectangle Tool Implemented



The latest edition to my Map Editor has been created, the Rectangle tool. Now I can easily create rows, columns of tiles to help fill up those empty spaces with simple things such as grass.

I also recoded how tile-sets are handled, so now they can only have a max height of 256, but 'technically' infinite width (4 billion pixels wide)

Currently making the saving system :D

Thursday, June 24, 2010

Learning the Source Engine (Valve)

Well for the past few days, Jacob has been creating a game design document, and I've been looking at the Source Engine, and by looking, I of course mean changing the slightest thing and breaking it completely, and having to start over.

Right now I've a fairly good idea on how to modify some things now so hopefully things will only get easier from here on out. Though everything Jacob mentioned in the design document might be a bit hard to implement :P

Tuesday, June 15, 2010

Map Editor can now PLACE tiles :)



The map editor can now place tiles, of course its very limited at the moment. I still need to make basic tools to make tiling easier, such as a fill tool, rectangle fill, etc.

I'll probably omit the filename text in the corner for some basic brush types to select such as those said above.

All thats left after that is moving the view position (to make the map bigger than one screen) and saving/loading system.

Monday, May 31, 2010

Hooray for the simplicity of C++

I've pretty much spent the entire night getting dialog boxes working all properly, unfortunately a small problem with Windows Dialog Boxes is that without setting a particular flag, they change the working directory, meaning anything you are loading relatively will fail.

Before:
opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT) & ~OFN_ALLOWMULTISELECT;


After:
opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR) & ~OFN_ALLOWMULTISELECT;


2 hours lost simply because I needed to write append the "OFN_NOCHANGEDIR" flag to the list.

Tuesday, May 25, 2010

Map Editor Progress 2



Still working on the map editor, since the last time I talked about it, I've implemented a better looking selector, changing which page its on (instead of scrolling as tilesets can be ANY size and I feel this is a better way to manage it, you can also type the page number, not only use the arrows)

The Brush selection is done, so you in the future you can select between rectangle collision boxes, triangle collision polygons, tiles and objects when creating the map.

The part I need to work on now is loading a tileset, but before doing that I need to fix my Textbox object as I've broken it, so now you can't type in them :S

Wednesday, May 12, 2010

My Map Editor Progress



Currently I'm working on the Map Editor for my Game engine. This is taking me forever to do mainly just because getting motivated to work on this is hard as it is VERY boring.

So well, now it can load a tilesheet by any width or height as it is divided into pages. (Page selector now yet implemented but it wont take much effort)

All thats needed now is the ability for the user to load a custom tile, load a map file, save a map file, create tiles on screen, create collision bounding boxes, and creating game objects...

... too much work to be done.

Thursday, April 29, 2010

Its been a while.

Eh, haven't really payed much attention to this blog lately. But I honestly had nothing to blog about, till now. When its 3am and I'm bored.

Firstly, I got the game Battlefield Bad Company 2, which is basically the overrated Call of Duty Modern Warfare 2 but with tanks, choppers, and destructible buildings. Its great fun as you make your own doorways for buildings amongst the chaos.

Secondly, I just whipped up some pseudo-code for the map editor of my program. This is basically to help me view a tileset sprite easily no matter what the dimensions the BMP are. Which will be useful if I just was to cut and paste random tilesets off from the interwebs.

Oh and the code for getting which section of the slice to show is:

VTILE_VIEW = ROUNDUP(HTILE*page);
HTILE_VIEW = page*VTILE_VIEW;

EDIT: It seems that pseudo-code was written wrong, but I guess thats what 3am does to you, fixed (in C++ code and Psuedo code):

Code:
tilev_view = (int)ceil((float)page/tileh_pages);
tileh_view = page-((tilev_view-1)*tilev_pages);

Psuedo:
VTILE_VIEW = ROUNDUP(PAGE/HTILE_PAGES);
HTILE_VIEW = page-((VTILE_VIEW-1)*VTILE_PAGES)


These variables will basically be manipulated later to show the first 200 pixels of the BMP or the 200 pixels after that and so forth. Basically so I can calculate what range of pixels to show on-screen.

(Tileset: A BMP filled with images that may represent walls, floor, buildings and etc in a 2D universe e.g.
)

Saturday, April 10, 2010

The iPhone had C++ support all along!

I wasn't aware that XCode for MAC allowed you to compile C++ code hand in hand with Objective-C. This means that I may be dual-booting Mac OSX in the future to get my programs running on iPhone/iPod Touch.

Don't hold your breath though, PC first, then Wii and PSP.

Tuesday, March 23, 2010

Assessment Item 2.

"A hermit lives in a cave. The cave's location within the world is determined by x, y & z coordinates. The hermit's name is Freeda and she is 100 years old. Many animals also live in the cave and they can talk. All of the animals have a first name & age. There are bats which fly & screech & there are lizards that run, hide & sing."

Below is my diagram for the above scenario, Basically my print screen is broken so this is a tad bit outdated, namely the return types aren't listed for the 'getters' but its pretty obvious anyway.

Monday, March 15, 2010

Objects with the new operator aka "a Constructor"



The constructor of the class allows for each object of 'Super Mario' to have a different amount of health and lives. Otherwise other details are the same.

Tuesday, March 2, 2010

Composition and Relationships



Here is a basic example of composition and relationships. The player can wield the object known as "Shotgun". The "Shotgun" is also a child object or to be put more clearly, inherits the properties of the object "Weapon".

Object Encapsulation



Here is an example of a Super Mario class, he has health, lives, a variable to see if he is currently suspended in air or not (isJumping) and score. These are encapsulated and can only be accessed outside the object via the functions such as SetScore(),GetScore(),SetLives(),GetLives() and more. These are called Accessors and Mutators. Accessors are the functions with the prefix "Get" and they do exactly that. They obtain the value safely to prevent errors. Mutators are the functions with the prefix "Set" and they set the value safely and everything related to that value.

Functions, Subroutines and Parameters

Function: A function is basically a process which takes input and provides an output, for example, Printing a page from a printer. The parameters are the text, images, and anything else on the page to send to the printer. The printer then uses this information accordingly to process the data and returns the output, which in this case, is paper.

Subroutine: A subroutine is a process that can take input but does not provide an output. An example of this is doing a task for someone without reaping any benefits or rewards, the task still gets done but nothing is given to you (except maybe the tools to do the job, aka the parameters). So you could be cleaning up the garden, and a parameter might be the tool you use, one day you might use the lawn mower, whilst another day you might use cutting tools to clean up bushes. This is probably a bad example but it is quite hard to explain subroutines in 'real world' terms.

In programming subroutines are usually used to keep code easy to read and repeat code with slightly different scenarios (this is where parameters come in)

Tuesday, February 23, 2010

Basic VB.NET Calculator



In class this week we had to make a simple calculator program, So we pretty much just had to follow a design, and use our knowledge of VB.NET variables and object functions.



Above is the source code to my calculator application, the commenting is pretty much self explanatory. I also added a division by zero checker so that the program won't crash.

Tuesday, February 16, 2010

3 Examples Arrays

1. Lists: Arrays can be used for listing data such as names or values. For example an array could be used to store your shopping list and view it.

2. Linking Numbers and Strings: Arrays allow you to use an index number which means things like the Chisholm student ID could be sent to the server, and return your name and other various details with precision, efficiency and ease.



3. String: A string is actually an array made up of letters (single bytes) and these are used often in almost all programming languages. The size of a string is simply the amount of letters plus one. It's 'plus one' to the size of the text because it ends in a byte with the value of zero (Null), this helps to tell the computer its finished reading the text.



4. Simulating Objects: Using a collection of arrays you can store various object names and data such as health, power, and more. This method of object orientated design is incredibly limited as it assumes all objects share the same states/variables. You would only use this for machines lacking dramatically in CPU and RAM power. YOU DO NOT NEED TO KNOW THIS AND ITS BAD PRACTICE TO USE IT IN OBJECT ORIENTATED PROGRAMS LIKE VISUAL BASIC

Monday, February 15, 2010

Imaginary Object. States and Behaviours




In class we had to get an object and describe the different states/variables and behaviors with parameters. Usually for functions inside objects you don't have to give them parameters but I thought "Meh, might as well."

EDIT: Fixed up the table to fit proper conventions.

Datatypes in the Wild exercise





I had to create a table showing what each variables/states data type is for the game character shown in the screenshot above the table.

Sunday, February 14, 2010

2 Hours of trying to fix this... Way to simple.




I've spent the last two hours trying to fix a problem with my game engines depth system. Basically the depth system is so I can choose which images are drawn in which order (eg. Draw Tree Outside, Draw Window, Draw Walls, Draw Lamp) those drawn last will appear last on the screen.

In any case the problem was one slight typo... well an entire word being a typo. Anywho problem solved now, and it works fine :)

P.S. The first screenshot is the error, the second screenshot is the fix.

Tuesday, February 9, 2010



This is my web browser for my VB.NET beginner project, fairly simple. Here is the code:
' Quick Search for my favourite websites
If (txtAddress.Text.ToString().ToUpper = "GOOGLE") Then
txtAddress.Text = "http://www.google.com.au"
ElseIf (txtAddress.Text.ToString().ToUpper = "") Then
txtAddress.Text = "http://www.google.com.au"
ElseIf (txtAddress.Text.ToString().ToUpper = "CTRL") Then
txtAddress.Text = "http://www.cad-comic.com"
ElseIf (txtAddress.Text.ToString().ToUpper = "CAD") Then
txtAddress.Text = "http://www.cad-comic.com"
ElseIf (txtAddress.Text.ToString().ToUpper = "BLOG") Then
txtAddress.Text = "https://www.blogger.com/start"
ElseIf (txtAddress.Text.ToString().ToUpper = "BLOGGER") Then
txtAddress.Text = "https://www.blogger.com/start"
ElseIf (txtAddress.Text.ToString().ToUpper = "GAME") Then
txtAddress.Text = "http://gmc.yoyogames.com"
ElseIf (txtAddress.Text.ToString().ToUpper = "GMC") Then
txtAddress.Text = "http://gmc.yoyogames.com"
End If

' Go to the site
wbBrowser.Navigate(txtAddress.Text)

Monday, February 8, 2010

Class Concepts



This is some of the beginner work done in the Multimedia Class, we were given an object and we had to describe the states (variables) and behaviours (functions/modules), so here it is.

First post.

This is my blog, My name is Jake and currently I'm programming a C++ engine that I hope will eventually run on Wii, PSP, Windows and Linux.