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

Case Study Practice for CIE IGCSE Computer Science | CIE IGCSE 计算机科学案例分析实战演练

2026-07-20 15:59 · 本文部分内容由AI辅助创作

📚 Case Study Practice for CIE IGCSE Computer Science | CIE IGCSE 计算机科学案例分析实战演练

Case study questions in Cambridge IGCSE Computer Science challenge you to apply computational thinking to real‑world scenarios. You need to read requirements carefully, design algorithms, draw flowcharts, write pseudocode, and construct test plans. This article guides you through a complete worked example – an automatic pet feeder – so you can see exactly how to break down a problem, produce a structured solution, and check your work. Each step mirrors the marks available in Paper 2, helping you build confidence for the exam.

剑桥 IGCSE 计算机科学中的案例研究题目要求你将计算思维应用于真实场景。你需要仔细阅读需求、设计算法、绘制流程图、编写伪代码并构建测试计划。本文通过一个完整范例——自动宠物喂食器,一步步向你展示如何拆解问题、生成结构化答案并验证成果。每一步都对应 Paper 2 中的得分点,帮助你建立考试信心。


1. Understanding the Case Study Brief | 理解案例背景

Always begin by highlighting the inputs, processes, outputs, and constraints. For our automatic pet feeder, the system must dispense a set amount of dry food at two user‑programmed times each day. A weight sensor detects whether the bowl is already full; if it is, the feeder skips that meal. The user can also trigger one extra manual feed per day. The device has a small screen and three buttons: 'Set', 'Up', and 'Down'.

首先,高亮题目中的输入、处理、输出和限制条件。本案例的自动宠物喂食器需要每天在两个用户设定的时间投放固定量的干粮。重量传感器检测食盆是否已满;若满,则跳过该餐。用户每天还可额外触发一次手动喂食。设备配有一块小屏幕和三个按钮:'Set'、'Up' 和 'Down'。

Identify the key variables and modules: current time, scheduled times, portion size, bowl status (full or not), and manual feed counter. This clarity prevents you from missing requirements later.

识别关键变量和模块:当前时间、预设时间、分量大小、食盆状态(满或不满)以及手动喂食计数器。清晰的梳理能避免你后续遗漏需求。


2. Decomposing the Problem | 问题分解

Break the system into manageable functions. For the automatic feeder, we can list:

将系统拆解为可管理的功能模块。对于自动喂食器,可列出如下:

Such decomposition helps you design top‑down algorithms and allocate tasks to separate subroutines, just as expected in exam answers.

这种分解有助于你设计自顶向下的算法,并将任务分配给独立子程序,这正是考试答案所要求的。


3. Designing the Main Algorithm in Structured English | 用结构化英语设计主算法

Before drawing flowcharts or writing pseudocode, sketch the logic in structured English. This connects the brief to your solution without getting tangled in syntax.

在绘制流程图或编写伪代码之前,先用结构化英语勾勒逻辑。这样可直接将需求连接到方案,避免陷入语法细节。

START
  Initialise scheduled_time1, scheduled_time2, portion_size
  Set manual_feed_remaining = 1
  REPEAT every minute
    Get current_time
    Update display with current_time
    IF current_time equals scheduled_time1 OR current_time equals scheduled_time2 THEN
      CALL CheckBowl
      IF bowl is not full THEN
        Dispense portion_size
        Display "Meal dispensed"
      ELSE
        Display "Bowl full – meal skipped"
      ENDIF
    ENDIF
    Check button presses (Set, Up, Down) → CALL HandleButtons
  FOREVER
END

This narrative form is an excellent planning tool and can be directly refined into pseudocode.

这种叙述形式是极好的规划工具,可以直接精炼为伪代码。


4. Drawing a Flowchart for the Dispensing Logic | 为投放逻辑绘制流程图

Flowcharts visually confirm that your algorithm handles all conditions. The exam may ask for a specific section, like the meal‑time routine. Below is a description for the dispensing decision – you would draw it with standard symbols.

流程图可以直观验证算法是否处理了所有条件。考试可能要求绘制特定部分,例如用餐时间例程。下面是投放决策的描述——你需要用标准符号绘制出来。

The process starts with a terminator "Check meal time". A decision diamond asks "Current time = scheduled time?" If No, the flow returns. If Yes, a second diamond "Bowl full?" follows. If Yes, output "Meal skipped"; if No, dispense food and output "Meal dispensed". Arrows clearly show the paths. A separate branch handles the manual feed request.

流程以终止符 "检查用餐时间" 开始。判断菱形框询问 "当前时间 = 预设时间?" 如果否,流程返回。如果是,进入第二个菱形框 "食盆已满?"。若是,输出 "餐食已跳过";若否,投放食物并输出 "餐食已投放"。箭头清晰显示路径。另有一分支处理手动喂食请求。

Using correct symbols (rounded rectangles for start/end, parallelograms for I/O, rectangles for processes, diamonds for decisions) is essential for full marks.

使用正确的符号(圆角矩形表示开始/结束,平行四边形表示输入/输出,矩形表示处理,菱形表示判断)是获得满分的关键。


5. Writing Pseudocode with Exam Conventions | 按考试规范编写伪代码

CIE expects pseudocode that is clear, readable, and follows standard structures: INPUT/OUTPUT, IF … THEN … ELSE … ENDIF, CASE OF … ENDCASE, REPEAT … UNTIL, WHILE … DO … ENDWHILE, and FOR … TO … NEXT. You should use appropriate variable names and comments.

CIE 期望的伪代码是清晰易读且遵循标准结构的:INPUT/OUTPUT、IF … THEN … ELSE … ENDIF、CASE OF … ENDCASE、REPEAT … UNTIL、WHILE … DO … ENDWHILE 以及 FOR … TO … NEXT。你应使用恰当的变量名和注释。

Here is the pseudocode for the automatic feeder's main loop:

以下是自动喂食器主循环的伪代码:

PROCEDURE Main
  DECLARE scheduled1, scheduled2 : STRING
  DECLARE portion, manualCount : INTEGER
  DECLARE bowlFull : BOOLEAN
  scheduled1 ← "08:00"
  scheduled2 ← "18:00"
  portion ← 50  // grams
  manualCount ← 1
  REPEAT
    current ← GetTime()
    OUTPUT current
    IF current = scheduled1 OR current = scheduled2 THEN
      bowlFull ← CheckBowlSensor()
      IF bowlFull = FALSE THEN
        DispenseFood(portion)
        OUTPUT "Meal dispensed"
      ELSE
        OUTPUT "Bowl full – meal skipped"
      ENDIF
    ENDIF
    CALL HandleButtons(scheduled1, scheduled2, portion, manualCount)
    IF current = "00:00" THEN
      manualCount ← 1   // reset manual feed
    ENDIF
  UNTIL SystemOff
ENDPROCEDURE

Notice that sub‑procedures like CheckBowlSensor() and DispenseFood(n) keep the code modular – exactly what examiners reward.

注意,像 CheckBowlSensor() 和 DispenseFood(n) 这样的子程序使代码模块化——这正是考官喜欢看到的。


6. Handling Manual Feed and Button Settings | 处理手动喂食与按钮设置

The user interface involves three buttons. Pressing 'Set' cycles through clock‑setting, meal‑time programming, and portion adjustment. A dedicated manual feed button would be ideal, but the case study only provides Set, Up, Down. Therefore, we need a button combination or a menu to trigger manual feed – for example, holding 'Set' for three seconds. Your exam answer must clarify the mapping.

用户界面涉及三个按钮。按 'Set' 可循环设置时钟、编程用餐时间以及调整分量。一个专用的手动喂食按钮是最理想的,但案例只提供了 Set、Up、Down。因此,我们需要一个按钮组合或菜单来触发手动喂食——例如,长按 'Set' 三秒。你的考试答案必须明确这一映射。

Pseudocode for button handling might look like this:

按钮处理的伪代码可如下所示:

PROCEDURE HandleButtons(BYREF t1, BYREF t2, BYREF portion, BYREF manualC)
  button ← ReadButton()
  CASE OF button
    "Set": IF heldSeconds >= 3 THEN
             IF manualC > 0 THEN
               CALL CheckAndFeed(portion)
               manualC ← manualC - 1
             ELSE
               OUTPUT "Manual feed already used today"
             ENDIF
           ELSE
             MenuNavigate(t1, t2, portion)
           ENDIF
    "Up":   AdjustValue(+1)
    "Down": AdjustValue(-1)
  ENDCASE
ENDPROCEDURE

Always state assumptions (e.g., holding Set for three seconds) to demonstrate analytical thinking.

始终陈述假设(例如,长按 Set 三秒),以展示分析思维。


广告 / Sponsored

7. Testing with Normal, Boundary, and Erroneous Data | 使用正常、边界和错误数据进行测试

A thorough test plan convinces the examiner that your solution is robust. Design test cases for:

一份全面的测试计划能让考官确信你的解决方案是可靠的。请设计以下测试用例:

Test Category – 测试类别Example – 示例Expected Result – 预期结果
Normal – 正常Scheduled time reached, bowl not fullMotor dispenses 50 g; manual feed counter unchanged
Boundary – 边界Manual feed counter = 1, then usedCounter becomes 0; "Manual feed used" message
Erroneous – 错误User tries manual feed when counter = 0Error message; no food dispensed
Another boundary – 另一边界Bowl sensor shows full exactly at meal timeMeal skipped, but manual feed still possible if bowl subsequently emptied

Test data should include just‑above and just‑below thresholds. At midnight, ensure the manual counter resets to 1.

测试数据应包含刚好高于和低于阈值的值。在午夜,确保手动计数器重置为 1。


8. Refining with Validation and Error Messages | 通过验证和错误信息进行完善

Any input (e.g., portion size set by the user) must be validated. If a user tries to set a portion larger than the hopper capacity or a negative number, the system must reject it and display an informative message. Use constants for limits:

任何输入(例如用户设定的分量大小)都必须经过验证。如果用户试图设置大于储粮仓容量或负数的分量,系统必须拒绝并显示提示信息。使用常量表示限制:

CONSTANT MAX_PORTION = 200
IF newPortion > MAX_PORTION OR newPortion <= 0 THEN
  OUTPUT "Invalid portion – enter 1–200 g"
ELSE
  portion ← newPortion
ENDIF

This demonstrates defensive design – a key syllabus point.

这体现了防御式设计——教学大纲中的一个重点。


9. Trace Table for Algorithm Verification | 用于算法验证的追踪表

For a trace table exercise, the exam may ask you to complete a dry run. Here is a completed trace table for a sample scenario where the scheduled time is "08:00", bowlFull is FALSE, and portion is 50.

对于追踪表练习,考试可能会要求你完成一次干运行。以下是针对预设时间 "08:00"、bowlFull 为 FALSE、portion 为 50 的示例场景所完成的追踪表。

Line – 行号currentbowlFullportionmanualCountOutput – 输出
1"08:00"FALSE501"08:00"
2"Meal dispensed"

Practising trace tables with different branches (bowl full, manual feed used) helps you internalise program flow for exam questions that require you to complete missing values.

针对不同分支(食盆已满、已使用手动喂食)练习追踪表,有助于你内化程序流程,以便应对要求填写缺失值的考题。


10. Linking to Syllabus and Mark Schemes | 链接到教学大纲和评分标准

CIE Paper 2 assesses algorithm design (AO2) and programming problem‑solving (AO3). Marks come from correct structural logic, correct use of standard flowchart symbols or pseudocode, appropriate validation, and thorough testing. When you present a case study solution, always label your flowchart symbols, write comments in pseudocode, and number your test cases. These small habits align directly with mark scheme requirements.

CIE 的 Paper 2 评估算法设计(AO2)和编程问题解决(AO3)。得分点来自正确的结构逻辑、正确使用标准流程图符号或伪代码、适当的验证以及全面的测试。在呈现案例分析方案时,务必为流程图符号添加标注、在伪代码中写注释并为测试用例编号。这些小习惯直接对标评分标准要求。

In addition, linking each part of your solution to the scenario shows application mark awareness. For instance, saying "Bowl sensor is checked to prevent overfilling, which is a physiological hazard for the pet" demonstrates understanding of the real‑world context.

此外,将方案的每一部分与场景关联,体现了对应用分数的认知。例如,说明 "检查食盆传感器以防止溢出,这对宠物来说是生理危害",展示了对真实情境的理解。


11. Practice with Another Scenario: Smart Greenhouse | 实战另一场景:智能温室

Now apply the same methodology to a new brief: a greenhouse monitor that waters plants when soil moisture drops below a threshold, opens vents if temperature exceeds 28 °C, and logs data every hour. Decompose it, write the main loop, identify sensor inputs (moisture, temperature), and design test cases including borderline temperatures (27.9 °C, 28.0 °C, 28.1 °C). This self‑practice replicates exam tasks and strengthens your confidence.

现在将相同的方法运用到一个新案例:一个温室监控系统,在土壤湿度低于阈值时浇水,当温度超过 28 °C 时打开通风口,并每小时记录数据。分解问题,编写主循环,识别传感器输入(湿度、温度),设计测试用例,包括边界温度(27.9 °C、28.0 °C、28.1 °C)。这种自主练习复制了考试任务,能增强你的信心。

After writing the pseudocode, swap with a peer for review. Peer checking often reveals missing initialisations or incomplete error handling, exactly what examiners spot.

编写完伪代码后,与同学交换审阅。同伴检查常常能发现遗漏的初始化步骤或不完整的错误处理,这正是考官会抓住的地方。


12. Exam Day Strategy for Case Study Questions | 案例研究题的考试策略

During the exam, allocate time proportionally to marks. If a case study spans 15 marks, spend roughly 15–18 minutes. Read the scenario twice, highlight trigger words ('validate', 'display error', 'repeat every 10 seconds'), and jot down a quick decomposition before writing any formal answer. Use the back pages to sketch a rough flowchart first, then transfer a neat version to the answer space. For pseudocode, focus on correctness of logic rather than perfect language syntax; CIE pseudocode is deliberately relaxed.

考试中,按分数比例分配时间。如果一个案例研究题占 15 分,大约花 15–18 分钟。阅读场景两遍,高亮触发词('验证'、'显示错误'、'每 10 秒重复一次'),并在正式作答前快速写下分解草图。在背面页先画一个粗略的流程图,然后将整洁的版本誊写到答题区。伪代码方面,专注于逻辑的正确性,而非完美的语言语法;CIE 伪代码有意保持宽松。

Remember to leave two minutes at the end to check for missing loops, unvalidated inputs, or unhandled boundary cases. A clear, systematic approach can turn a complex scenario into a sequence of manageable steps, leading directly to top marks.

切记最后留出两分钟,检查是否遗漏循环、未验证的输入或未处理的边界情况。清晰、系统的方法可以将复杂场景转化为一系列可管理的步骤,直通高分。

Published by TutorHao | Computer Science Revision Series | aleveler.com

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

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

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