Lessons 51–52 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
52
Practical lesson
Textbook: pp. 115–116
GoalCreates applications with CheckBoxes that calculate a price and that control other objects as settings.
New words
OnClick of a CheckBox: the event when it is ticked or cleared · OnClick (CheckBox)total: the result of adding all selected parts · jamilinking: making one property follow another, such as Visible := Checked · bog‘lashinitial state: all boxes cleared at the start · boshlang‘ich holat
Explanation
In the practical lesson three applications are created. 1) “Pizza order”: the base price is 30000 so‘m; CheckBox1 – cheese (+5000), CheckBox2 – mushrooms (+4000), CheckBox3 – olives (+3000). When the button is pressed: s := 30000; if CheckBox1.Checked then s := s + 5000; … and Label1.Caption := 'Jami: ' + IntToStr(s) + ' som'; is shown. 2) “Settings”: in a CheckBox’s OnClick procedure the state of another object is tied to the tick, for example Label1.Visible := CheckBox1.Checked; and Button1.Enabled := CheckBox2.Checked; 3) “Tick all / clear”: two buttons set Checked of all CheckBoxes to True or False. Test each application and check the calculated total by hand.
💡 Where will I use this?
In real life
A class trip application has a basic fare, while the extras are optional: a museum ticket and a packed lunch. When a pupil ticks a box, the total updates by itself. Which extras are chosen decides the total exactly.
Who uses it
Developers of booking systems, designers of online services and event organisers calculate the total from the chosen extras.
Try it today
On paper make a list with a basic price of 10 units and extras of +2, +3 and +5 units, and calculate the total for three different choices.
Worked examples
Ticked extras
Total
cheese + olives
38000
all three
42000
nothing
30000
Cheese and olives ticked: s = 30000+5000+3000 = 38000. All three extras ticked: 30000+5000+4000+3000 = 42000. Nothing ticked: 30000.
In “Settings” CheckBox2 is “I agree to the terms” and Button1 is “Send”. CheckBox2’s OnClick contains Button1.Enabled := CheckBox2.Checked; At the start there is no tick, so the button is greyed out; when the box is ticked the button becomes enabled, and when the tick is removed it is greyed out again. In the same way Label1.Visible := CheckBox1.Checked; shows or hides the label according to the tick.
Class activity
“The order service”: a pair adds a fourth extra to the menu with its own price and checks the total for five of the 16 combinations of ticks, calculated in advance.
Practice
1
If only olives are ticked, what is the total (base price 30000, olives +3000)?
33000
2
If mushrooms and cheese are ticked, what is the total?
39000
3
How many combinations of ticks do three CheckBoxes have (each ticked or not)?
8
4
Why is a radio group more convenient than CheckBoxes for “choose one”?
A radio group ensures one choice by itself; no extra code is needed.