← 返回资讯屏轩教育 · 行业资讯

Year 8 CAIE Computer Science: Case Study Practical Exercises | Year 8 CAIE 计算机:案例分析实战演练

2026-07-18 09:52 · 本文部分内容由AI辅助创作

📚 Year 8 CAIE Computer Science: Case Study Practical Exercises | Year 8 CAIE 计算机:案例分析实战演练

In Year 8 CAIE Computer Science, theory comes to life when you apply what you have learned to a real‑world scenario. This article guides you through a complete case study – designing a simple smart home security system. You will practise identifying inputs and outputs, drawing flowcharts, writing pseudocode, building logic gate circuits, using binary data representation, testing with truth tables, and even considering networking and ethical issues. By working through each stage, you will develop the problem‑solving skills that are central to computational thinking.

在 Year 8 CAIE 计算机科学课程中,当你将所学知识应用于真实场景时,理论才真正鲜活起来。本文将通过一个完整的案例研究——设计简易的智能家居安防系统——带你进行实战演练。你将练习识别输入与输出、绘制流程图、编写伪代码、搭建逻辑门电路、运用二进制数据表示、利用真值表进行测试,甚至还会考虑网络连接与伦理问题。逐步完成这些环节,你就能培养出计算思维所必需的问题解决能力。


1. Introducing the Case Study: The Smart Home Security System | 案例介绍:智能家居安防系统

You have been hired as a junior systems designer by a technology company. Your task is to create the control logic for a basic smart security alarm. The system monitors two sensors – a door contact sensor and a passive infrared motion sensor – as well as an arming switch. The alarm should only sound if the system is armed AND at least one sensor is triggered. This mimics the behaviour of many real home alarm panels and gives you a clear set of requirements to work with.

你被一家科技公司聘为初级系统设计师。你的任务是为一个基础型智能安防报警器设计控制逻辑。该系统监测两个传感器——门磁传感器和被动红外运动传感器——以及一个布防开关。只有在系统已布防且至少有一个传感器被触发时,警报才会响起。这一要求模拟了许多真实家用报警主机的行为,为你提供了一套清晰的工作需求。

Throughout this exercise, you will use the problem‑solving cycle: understand the problem, plan a solution, implement the logic, test it, and evaluate extensions. All the computer science concepts you have studied – binary, logic gates, flowcharts, pseudocode, and simple networking – will be needed.

在整个练习过程中,你将运用问题解决循环:理解问题、规划方案、实现逻辑、测试方案并评估扩展。你所学的所有计算机科学概念——二进制、逻辑门、流程图、伪代码和简单网络知识——都将派上用场。


2. Identifying Inputs, Process, and Outputs | 识别输入、处理与输出

Every computer system can be broken down into three fundamental parts: input, process, and output. For our security system, the inputs are the signals from the physical world that the microcontroller will read. We have three inputs: Arming switch (A) – value 1 when the user has armed the system, 0 when disarmed; Door sensor (D) – value 1 if the door is open, 0 if closed; and Motion sensor (M) – value 1 if movement is detected, 0 if no movement. These are all simple digital on/off signals, perfect for binary logic.

每个计算机系统都可以分解为三个基本部分:输入、处理和输出。对于我们的安防系统,输入是微控制器将要读取的来自物理世界的信号。我们共有三个输入:布防开关 (A)——用户设防时值为1,撤防时为0;门磁传感器 (D)——门打开时值为1,关闭时为0;运动传感器 (M)——检测到运动时值为1,无运动时为0。这些都是简单的数字开/关信号,非常适合使用二进制逻辑。

The process is the decision‑making carried out by the microcontroller. It will repeatedly read the three input values and apply a logical rule to decide whether to activate the output. The only output in the basic version is an alarm siren (Alarm) which is ON (1) or OFF (0). A small status LED could also indicate arming state, but the core output is the alarm. Keeping the outputs simple helps us focus on the logic.

处理过程是由微控制器执行的决策过程。它会反复读取三个输入值,并应用一条逻辑规则来决定是否激活输出。在基本版本中,唯一的输出是警报器 (Alarm),其状态为开 (1) 或关 (0)。一个小型状态指示灯也可以显示布防状态,但核心输出是警报器。保持输出简洁有助于我们专注于逻辑设计。


3. Designing the Algorithm: Flowchart | 设计算法:流程图

Before writing any code, we design the step‑by‑step algorithm using a flowchart. Flowcharts use standard symbols: ovals for Start/End, parallelograms for Input/Output, rectangles for processes, and diamonds for decisions. Our system repeats forever, so the flowchart contains a loop. The logic: read A, D, M; if A is 1 (armed) then check if D is 1 OR M is 1; if this second condition is true, turn the alarm ON; otherwise turn it OFF. If the system is not armed, the alarm stays OFF.

在编写任何代码之前,我们先使用流程图设计分步算法。流程图采用标准符号:椭圆表示开始/结束,平行四边形表示输入/输出,矩形表示处理过程,菱形表示判断。我们的系统会永续循环,因此流程图中包含一个循环。逻辑如下:读取 A、D、M;如果 A 为 1(已布防),则检查 D 是否为 1 或者 M 是否为 1;如果这第二个条件成立,就打开警报器;否则关闭警报器。如果系统未布防,警报器保持关闭。

The flowchart sequence can be described as: Start → Input A, D, M → Decision: Is A = 1? o, set Alarm = 0 and loop back to Input. If Yes, enter another decision: Is D = 1 OR M = 1? he sensors again. This ensures continuous monitoring, exactly like a real security system.

流程图顺序可以描述为:开始 → 输入 A, D, M → 判断:A = 1?→ 如果否,将 Alarm 置 0 并回到输入步骤。如果是,进入另一个判断:D = 1 或 M = 1?→ 如果是,将 Alarm 置 1;如果否,将 Alarm 置 0。设置完警报状态后,回到开头再次读取传感器。这样就实现了持续监控,就像真实安防系统一样。


4. Translating the Flowchart to Pseudocode | 将流程图转换为伪代码

Pseudocode is a readable description of the algorithm that uses programming‑like structures but avoids strict syntax. For our system, the pseudocode must include a loop, conditional statements, and input/output commands. We use WHILE true to create an infinite loop. The keywords INPUT and OUTPUT represent reading sensors and controlling the alarm. The condition uses AND and OR operators just like in the logic specification.

伪代码是对算法的可读描述,使用类似编程的结构但避免了严格的语法。对于我们的系统,伪代码必须包含循环、条件语句和输入/输出命令。我们使用 WHILE true 来创建无限循环。关键字 INPUT 和 OUTPUT 分别代表读取传感器和控制警报器。条件判断使用 AND 和 OR 运算符,与逻辑规约完全一致。

A clear pseudocode solution is:

WHILE true
  INPUT armed, door, motion
  IF armed = 1 AND (door = 1 OR motion = 1) THEN
    OUTPUT alarm ← 1
  ELSE
    OUTPUT alarm ← 0
  ENDIF
ENDWHILE

一个清晰的伪代码方案如下:当条件为真时循环(无限循环),读取 armed, door, motion;如果 armed 等于 1 且 (door 等于 1 或 motion 等于 1),则输出报警 1;否则输出报警 0。这段伪代码直接对应我们的流程图,并且稍加修改就可以转换成真实的编程语言代码。


5. Logic Gate Implementation: AND & OR Conditions | 逻辑门实现:与门和或门条件

At the hardware level, the decision‑making can be built with simple logic gates. The Boolean expression for the alarm is: Alarm = A AND (D OR M). This requires one OR gate and one AND gate. Connect the door sensor D and motion sensor M to the two inputs of an OR gate. The output of this OR gate is then fed into one input of an AND gate; the other AND input is connected to the arming signal A. The final AND output drives the alarm.

在硬件层面,决策过程可以用简单的逻辑门来搭建。警报器的布尔表达式为:Alarm = A AND (D OR M)。这需要一个或门和一个与门。将门磁传感器 D 和运动传感器 M 连接到或门的两个输入端。这个或门的输出再送入与门的一个输入端;与门的另一个输入端连接布防信号 A。与门的最终输出驱动警报器。

You can think of the OR gate as a 'motion or door open' detector: it outputs 1 if either sensor is triggered. The AND gate then acts as the 'armed check': it only allows the alarm to sound when the system is armed AND the detector reports a disturbance. This combination of gates is a classic example of a simple combinational logic circuit.

你可以把或门想象成一个“运动或开门检测器”:只要任一传感器被触发,它就输出 1。与门则充当“布防检查”:只有当系统布防且检测器报告异常时,才允许警报响起。这种门电路的组合是简单组合逻辑电路的经典例子。

Logic equation: Alarm = A · (D + M)

逻辑方程:Alarm = A · (D + M)

In the equation, the dot (·) represents AND and the plus (+) represents OR. This shorthand is used in Boolean algebra, a topic you will explore further in later years.

在方程中,点号 (·) 表示与运算,加号 (+) 表示或运算。这种简写方式用于布尔代数,你将在高年级进一步学习该主题。


广告 / Sponsored

6. Representing Data in Binary | 用二进制表示数据

Microcontrollers work with binary numbers – for storage or transmission. For instance, we can assign each signal a bit position in a 3‑ y 101₂ (bit 2=1, bit 1=0, bit 0=1) means armed, door closed, motion detected, which has decimal value 5.

微控制器使用二进制数——由 0 和 1 组成的序列——进行工作。我们的三个输入信号 (A, D, M) 可以组合成一个二进制值,用于存储或传输。例如,我们可以为每个信号分配一个 3 位数中的比特位:令第 2 位为 A,第 1 位为 D,第 0 位为 M。二进制模式对应的十进制值可以帮助我们快速识别状态。二进制读数 101₂(第2位=1,第1位=0,第0位=1)表示已布防,门关闭,检测到运动,其十进制值为 5。

A table showing all possible binary input combinations makes the system behaviour crystal clear:

A (bit 2)D (bit 1)M (bit 0)BinaryDecimal
000000₂0
001001₂1
010010₂2
011011₂3
100100₂4
101101₂5
110110₂6
111111₂7

上表展示了所有可能的二进制输入组合,使系统行为一目了然。在真实设备中,这些 1 和 0 可能存储为一个字节中的低三位,其余高位填 0。理解二进制表示对于排查故障和向其他设备(如智能手机)发送状态数据至关重要。


7. Testing with a Truth Table | 使用真值表进行测试

row ensures there is no hidden mistake. The table has columns for A, D, M, D OR M, and Alarm. You would fill in the intermediate column first, then apply the AND with A to obtain the final alarm state.

真值表列出了所有可能的输入组合,并根据逻辑方程 Alarm = A AND (D OR M) 给出期望输出。测试每一行可以确保没有隐藏的错误。表格包含 A、D、M、D OR M 和 Alarm 列。你先填写中间列 D OR M,然后将其与 A 进行 AND 运算,得到最终的警报状态。

ADMD OR MAlarm
00000
00110
01010
01110
10000
10111
1101
广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao