☰ Contents · Computing

CheckBox and the array

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.

Worked examples
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)?
2
If mushrooms and cheese are ticked, what is the total?
3
How many combinations of ticks do three CheckBoxes have (each ticked or not)?
4
Why is a radio group more convenient than CheckBoxes for “choose one”?