Tuesday 15 October 2013

Proximity detection

1.
Problem:  The players proximity to the bomb needs to be detected
Inputs:  playerLocX, playerLocY, bombX, bombY
Outputs:  Color.colour of oval graphic

Processing:  All players
if playerLocX > bombX - 20
and
playerLocX < bombX + 20
and
playerLocY > bombY - 20
and
playerLocY < bombY + 20
then
change graphic set colour
draw oval

Pseudocode
Players proximity to bomb

Get playerLocX, playerLocY, bombX, bombY

if playerLocX > bombX - 20
and
playerLocX < bombX + 20
and
playerLocY > bombY - 20
and
playerLocY < bombY + 20
then
change graphic set colour
draw oval
else
end

2.
Problem:  The players proximity to other players needs to be detected
Inputs:  playerLocX, playerLocY
Outputs:  Color.colour of graphic oval
Processing:  All players
if playerLocX > playerLocX - 20
and
playerLocX < playerLocX + 20
and
playerLocY > playerLocY - 20
and
playerLocY < playerLocY + 20
then
change graphic set color
draw oval

Pseudocode
Players proximity to other players

Get playerLocX, playerLocY

if playerLocX > playerLocX - 20
and
playerLocX < playerLocX + 20
and
playerLocY > playerLocY - 20
and
playerLocY < playerLocY + 20
then
change graphic set color
draw oval
else
end

Thursday 26 September 2013

For Loops

1.  The 3 things that need to be set when priming a For Loop are the initialization, termination and the increment.
2.  The amount of times the example will print the world hello is 10.

Tuesday 3 September 2013

Update environment variables 2 - implementation


Update environment variables 2 - algorithm

1.  The problem is that the environment variables need to be calculated.
2.  The inputs of this algorithm are X, Y and R.
3.  The outputs of this algorithm are X and Y.
4.  The processing tasks are Y incremented by R, If Y > 100 then X decremented by 10 and If Y > 200 then X and Y equal 0.
5.  Pseudocode

Update environment variables 2
Prompt user for X, Y, R

Get X, Y, R

Y = Y + R
If Y > 100
X = X - 10
If Y > 200
X = 0
Y = 0

End

Monday 26 August 2013

Update Environment Variables - algorithms

1. The problem is that the environment variables need to be calculated to be updated.
2. The inputs are X, Y, R and T.
3. The outputs are X and Y.
4. The processing tasks are X incremented by R and Y incremented by T.
If X > 5000 then Y decremented by 1000.
If Y < 0, Y and X are set to 0.
5. Pseudocode

Update environment variables
Prompt user for X, Y, R and T

Get X, Y, R and T
X = X + R
Y = Y + T

If X > 5000
Y = Y - 1000

If Y < 0
Y = 0
X = 0

End


Tuesday 20 August 2013

Object modelling

TV remote
Attributes:  Buttons, Batteries, Brand, Colour
Behaviours:  Button press

USB
Attributes:  Brand, Colour, USB slot, Data capacity
Behaviours:  USB port insert

Phone
Attributes:  Numpad, Battery, Sim Card, SD card, Mic, Touch screen
Behaviours:  Makes calls, recieves calls, touch sensitive

Tuesday 13 August 2013

Switch flowchart


Switch

Switch Month
Case condition 1
Display "The number is 1"

Case condition 2
Display "The number is 2"

Case condition 3
Display "The number is 3"

Case condition 4
Display "The number is 4"

Case condition 5
Display "The number is 5"

Case condition 6
Display "The number is 6"

Case condition 7
Display "The number is 7"

Case condition 8
Display "The number is 8"

Case condition 9
Display "The number is 9"

Case condition 10
Display "The number is 10"

Case condition 11
Display "The number is 11"

Case condition 12
Display "The number is 12"

Case Else
Prompt user to re-enter value

End Select

And

The value that needs to be stored in Number to display the message "This number does not meet the condition" are 7 or less or 11 or higher.

Monday 12 August 2013

Or

The numbers 5, 6, 7 and 8 would need to be stored in Number to make the program display the message "This number does not meet the condition".

Validation and error trapping

1. 
Pseudocode
Calculate price of sending parcel
Prompt user for ItemWeight, CostPerKilo
Get ItemWeight, CostPerKilo

If ItemWeight is a number and CostPerKilo is a number
 
CostofSendingParcel = ItemWeight * CostPerKilo
If CostofSendingParcel < 100
Display CostofSendingParcel
Else
CostAfterDiscount = CostofSendingParcel * 0.9
Display CostAfterDiscount
End If

Else Display ErrorMessage
 
End
2.
 

Tuesday 6 August 2013

Apply Discount

 
Apply discount algorithm
 
Defining the problem:
The problem is that we need to find the cost of sending a parcel to someone and calculating the discount if the cost is more than $100.
 
Defining the inputs:
The inputs are; ItemWeight, CostPerKilo
 
Defining the outputs:
The outputs are; CostofSendingParcel, CostAfterDiscount
 
Define the processing:
1.  Get the item weight
2.  Get the cost per kilo
3.  Calculate the cost of sending a parcel
4.  If the cost of sending a parcel is less than $100, display the cost of sending a parcel
5.  Else, apply a 10% discount
6.  Display the cost after discount
 
Pseudocode
Calculate price of sending parcel
Prompt user for ItemWeight, CostPerKilo
 
Get ItemWeight, CostPerKilo
 
CostofSendingParcel = ItemWeight * CostPerKilo
 
If CostofSendingParcel < 100
Display CostofSendingParcel
Else
CostAfterDiscount = CostofSendingParcel * 0.9
Display CostAfterDiscount
End If
End

Monday 5 August 2013

Flowchart 1



Send a parcel algorithm

Task 1
1.  The problem is that we need to find the price of sending a parcel.
2.  The inputs are the weight of the parcel and the price per kiloram.
3.  The output is the final cost of sending the parcel.
4.
i) Get the items weight
ii) Get the standard charge per kilo
iii) Calculate the price of sending the item
iv) Display the price of sending the item
5.  Pseudocode
Calculate price of sending parcel

Prompt user for ItemWeight, CostPerKilo
Get ItemWeight, CostPerKilo
CostofSendingParcel = ItemWeight*CostPerKilo
Display CostofSendingParcel

Task 2
The steps ti creating an algorithm are:
Step 1: Define the problem
Step 2: Define the inputs
Step 3: Define the outputs
Step 4: Define processing
Step 5: Write the pseudocode

Thursday 11 July 2013

Java building blocks

Printing to console - 1.  The difference between the print() and println() method is that println() will terminate the line, but print() will allow you to continue the line.
Getting input - 2.  The nextInt() method of the scanner class only accepts whole numbers.

Methods - 3.  A procedure executes processing statements, while a function performs processing and returns a value.  The parameters of a

Variables - 4.  A variable is used to store values inside programs so they can be used again.  The syntax for declaring a variable is:  Type identifier = value;.
String - 5.  The string function that returns the number of characters in a specific string is called the String length() function.
Concatenation - 6.  The concatenation operator is also used as the addition operator.
Int - 7.  The value stored in an int will always be a whole number.
Double - 8.  The value stored in a double will come as a floating point number.
Boolean  - 9.  The value stored as a boolean will be a true false statement.
Constants - 10.  The difference between a constant and a variable is that unlike variables, a constant can not be changed through processing.
Arithmetic - 11.  The addition operator is used to add together values, the subtraction operator subtracts values from each other, the multiplication operator is used to multiply values together, the division operator is used to divide values,
String functions - 12.  The String.valueOf function can be used to have working equations in the code.

Tuesday 18 June 2013

Simple WoW stuff

A character in WoW has 5 base character attributes:  strength, agility, stamina, intellect and spirit.

There are 7 calculated character statistics for each player.

The player stats are calculated based on the combination of the race and class, so that class bonus' are added on to base race attributes.

PlayerStats = BaseRaceAttributes + ClassEffects

The health of a character is calculated using the following equations: 
If Stamina is less than 20:

    Health = BaseHealth + (Stamina - 20)



If Stamina is greater than or equal to 20:

    Health = BaseHealth + 10 * (Stamina - 20)

The mana of a character is calculated using the following equations: 
If Intellect is less than 20:

    Mana = BaseMana + (Intellect - 20)



If Intellect is greater than or equal to 20:

    Mana = BaseMana + 15 * (Intellect - 20)

Calculated player mana algorithm
Calculated player health algorithm

Tuesday 4 June 2013

Maths

+ is the addition operator
- is the subtraction operator
* is the multiplication operator
/ is the division operator

Monday 3 June 2013

Compiling a Java program

1.  The 2 main components of the Java platform are the Java Virtual Machine and the Java Application Programming Interface.
2.  The file extension of a Java source code file is the .java extension.
3.  The file extension of a file that has been compiled is the javac compiler.
4.  The name of the Java compiler is the javac compiler.
5.  The type of code contained by a .class is called bytecodes.
6.  The language of the Java Virtual Machine is bytecodes.
7.  Libraries of related classes and interfaces are called packages.

Introduction

Hi, i'm Tyson and this is my new blog.  I'll be using this blog to record pieces of code so that I can come back to this in the future.