Curriculum Challenges 3.1
- Write a subroutine that can be called to welcome a user and tell them how long it was since they last started SmallBasic
Hint: store the last time in a file in the current Program.Directory. - List all of the SmallBasic files in current Program.Directory.
- Create a file in the current Program.Directory and use it to store a some sums that can be added to for the text challenge bellow.
Text Challenges
- Write a program that can do as many of the following sums as you can and output the answers.
The sums are input at text strings like “25+3” which need to be scanned and interpreted (parsed) to find the numbers and operations to do the sum (this is a Text challenge).
The program should read the sums from a file (created by curriculum challenge 3 or created manually).
Add or share more sums to test each other’s programs.
Example sums
-
- 25+3
- 15.7*91
- -12-8
- sqrt(81)
- 5+sqrt(9)
- (7+5)/4
Graphical Challenges
- Make a simple graphical calculator.
Perhaps the user enters 2 numbers in 2 textboxes and then presses one of 4 buttons to +, -, *, / with the result given in a third textbox.
Maths Challenges
- Write a program to calculate the number of ways that a ‘full house’ can be chosen by picking 5 cards from a normal pack of cards.
A full house has 3 of a kind and 2 of a kind.
Perhaps also do some other poker hands like a flush or straight. - You can try doing it randomly to get the approximate probability of such hands.
Remember any card can only be picked once so if I have already got two 8s, the chances of getting a third are reduced.
Game Challenge
- Write ‘pairs game’ where the players have to find image pairs.
Something like this.
Community Suggestions
by Nonki
- Draw G clef and F clef.
- Draw wave figures of chords (e.g. C major, F minor, G 7th).
- Make a scoreboard for any sports.
Challenges
by Jibba Jabba
Properties and Operations
Briefly explain the difference between an Operation and a Property.
Using the words “has” and “does”.
For beginners.
TextWindow Challenge: – for intermediate skill level
Write a program that changes the TextWindow.BackgroundColor to all the colours available to the TextWindow and display (animate) the current color’s name in the TextWindow.Title.
To set TextWindow.BackgroundColor: 1st set the color then clear the window.
Good Coding Techniques
Identify/discover the usefulness of using good variables as opposed to just plugging values straight into functions and methods.
This is a 1st step toward writing extensible code.
May as well briefly define a function and method too.
This article can help: Small Basic: Programming Tips
GraphicsWindow Challenge: – for beginner gamers
Using your good variables add a box (rectangle) or a ball (ellipse) and continuously move it from one side of the window to the other so that no part of the shape leaves the window but the Shape touches the edge.
Use Shapes.Move method and not Shapes.Animate().
You can further advance this (intermediate skill level) by using acceleration so that the shape is moving at its fastest in the centre of the GraphicsWindow and slowest at the edges.