📚 AS CIE Computer Science: Case Study Practical Walkthrough | AS CIE 计算机:案例分析实战演练
This article provides a detailed walkthrough of a case study for AS CIE Computer Science, focusing on a Library Management System. You will see how to apply analysis, design, pseudocode, testing and evaluation in a structured manner, helping you tackle the case study component confidently.
本文针对 AS CIE 计算机科学课程,详细讲解一个图书馆管理系统案例的实战演练。你将看到如何系统性地进行分析、设计、伪代码编写、测试和评估,从而掌握应对案例分析题的方法。
1. Case Study Introduction | 案例介绍
Our case study is a simple Library Management System intended for a small community library. The system must keep track of books, borrowers and borrowing transactions. It will be used by librarians to manage the catalogue and handle book lending.
我们的案例是一个面向小型社区图书馆的简单图书馆管理系统。该系统需要记录图书、借阅者和借阅交易,由图书管理员用来管理馆藏目录并处理图书借阅。
The core functional requirements are: add new books to the system, search for a book by its title or ISBN, lend a book to a borrower, return a borrowed book, and display a list of all books currently in the library.
核心功能需求包括:向系统中添加新书、按书名或 ISBN 搜索图书、将图书借给借阅者、归还已借出的图书,以及显示图书馆当前所有图书的列表。
Non‑functional requirements focus on ease of use, a clear text‑based menu interface, and the ability to maintain data persistently between sessions using a simple file or database. The solution will be structured in a modular way using separate procedures for each major task.
非功能性需求侧重于易用性、清晰的文本菜单界面,以及通过简单文件或数据库在会话之间持久保存数据的能力。解决方案将采用模块化结构,每个主要任务使用独立的子程序。
2. Requirements Analysis | 需求分析
Before designing, the analyst must identify the inputs, processes and outputs. The main inputs are: new book details (ISBN, title, author, year, number of copies), borrower ID when lending, and search keywords. The outputs are: search results, confirmation of successful lending or returning, and the full book list.
在设计之前,分析师必须确定输入、处理和输出。主要输入包括:新书详情(ISBN、书名、作者、年份、副本数量)、借阅时的借阅者 ID 以及搜索关键词。输出包括:搜索结果、借阅或归还成功的确认信息以及完整的图书清单。
Processes include adding a record to the books data structure, searching the data structure for matching titles or ISBNs, updating the available copies count when lending or returning, and handling edge cases such as searching for a non‑existent book or trying to lend a book with zero available copies.
处理过程包括:向图书数据结构中添加记录、在数据结构中搜索匹配的书名或 ISBN、在借阅或归还时更新可借副本数,以及处理边界情况,例如搜索不存在的图书或尝试借出副本数为零的图书。
Additionally, the system must validate input data: ISBN should be a 13‑digit number, year should be a valid integer, and copies must be a positive integer. Validation routines will be built into the add‑book module.
此外,系统必须验证输入数据:ISBN 应为 13 位数字,年份应为有效整数,副本数必须为正整数。验证例程将内置在添加图书模块中。
3. System Design Overview | 系统设计概览
The system will be designed using a modular approach. A main menu procedure displays options to the user. Each option triggers a dedicated procedure: AddBook, SearchBook, LendBook, ReturnBook, and ListBooks. A global data structure stores all book records in memory during runtime, with data loaded from a text file or database at startup and saved back on exit.
系统将采用模块化方法设计。主菜单过程向用户展示选项,每个选项触发一个专用过程:AddBook、SearchBook、LendBook、ReturnBook 和 ListBooks。一个全局数据结构在运行时存储所有图书记录,启动时从文本文件或数据库加载数据,退出时保存回去。
The design uses a record type to represent a book: TYPE BookRecord
ISBN : STRING
Title : STRING
Author : STRING
Year : INTEGER
Copies : INTEGER
Available : INTEGER
ENDTYPE. A 1‑D array of BookRecord will hold the entire catalogue, with a variable storing the current count of books.
设计使用记录类型来表示一本书:TYPE BookRecord
ISBN : STRING
Title : STRING
Author : STRING
Year : INTEGER
Copies : INTEGER
Available : INTEGER
ENDTYPE。一个一维 BookRecord 数组将保存整个目录,并用一个变量存储当前图书数量。
The user interface is text‑based. A sample main menu is:
1. Add new book
2. Search for a book
3. Lend a book
4. Return a book
5. List all books
6. Exit
Users enter a number, and the corresponding procedure is called.
用户界面是基于文本的。示例主菜单为:
1. 添加新书
2. 搜索图书
3. 借出图书
4. 归还图书
5. 列出所有图书
6. 退出
用户输入数字,调用相应的过程。
4. Data Structures and Algorithms | 数据结构与算法
A static array of records will hold up to 1000 books. The chosen search algorithm is linear search, which is straightforward to implement and sufficient for a small collection. For each search, the procedure loops through the array comparing the search key with the title (or ISBN) field.
一个包含最多 1000 本书的静态记录数组将作为存储结构。选择的搜索算法是线性搜索,它易于实现,对于小型馆藏来说已经足够。每次搜索时,该过程会遍历数组,将搜索键与书名(或 ISBN)字段进行比较。
Lending and returning modify the Available field. Lending requires checking that Available > 0; returning increases Available by one. Both operations also need to identify a borrower – in this simple system we assume each borrower has a unique ID, which the librarian enters.
借阅和归还操作会修改 Available 字段。借阅时需要检查 Available > 0;归还时将 Available 增加 1。这两种操作还需要识别借阅者——在这个简单系统中,我们假设每位借阅者都有唯一 ID,由图书管理员输入。
A transaction log could be kept in a separate CSV file to record BorrowID, BookID, BorrowerID, DateOut, DateDue. This demonstrates an understanding of file handling. The pseudocode for reading the book file on startup will use OPENFILE and READFILE statements.
交易日志可以保存在单独的 CSV 文件中,记录借阅 ID、图书 ID、借阅者 ID、借出日期和应还日期。这展示了对文件处理的理解。启动时读取图书文件的伪代码将使用 OPENFILE 和 READFILE 语句。
5. Pseudocode for Core Functions | 核心功能伪代码
Pseudocode for adding a book:
添加图书的伪代码:
PROCEDURE AddBook
INPUT ISBN, Title, Author, Year, Copies
IF validation fails THEN
OUTPUT "Invalid data"
RETURN
ENDIF
BookCount ← BookCount + 1
Books[BookCount].ISBN ← ISBN
Books[BookCount].Title ← Title
Books[BookCount].Author ← Author
Books[BookCount].Year ← Year
Books[BookCount].Copies ← Copies
Books[BookCount].Available ← Copies
OUTPUT "Book added successfully"
ENDPROCEDURE
This procedure first validates the inputs. If any field fails the check, it outputs an error and exits. On success, it increments the book counter and stores all details in the next available slot of the array. The available copies are initialised to the total number of copies.
该过程首先验证输入。如果任何字段未通过检查,则输出错误并退出。如果成功,它会递增图书计数器,并将所有细节存储在数组的下一个可用槽中。可借副本数初始化为副本总数。
Pseudocode for searching by title (case‑insensitive linear search):
按书名搜索的伪代码(不区分大小写的线性搜索):
PROCEDURE SearchByTitle(SearchTitle)
Found ← FALSE
FOR i ← 1 TO BookCount
IF UCASE(Books[i].Title) = UCASE(SearchTitle) THEN
OUTPUT Books[i].ISBN, Books[i].Title, Books[i].Available
Found ← TRUE
EXIT FOR
ENDIF
NEXT i
IF NOT Found THEN
OUTPUT "No matching book found"
ENDIF
ENDPROCEDURE
The loop iterates through all books. UCASE() is used to ignore case. If a match is found, the book details are printed and the loop terminates early. If the loop finishes without a match, a message is displayed.
循环遍历所有图书。UCASE() 用于忽略大小写。如果找到匹配项,则打印图书详情并提前终止循环。如果循环结束仍未找到匹配项,则显示一条消息。
6. Implementing Lend and Return Logic | 实现借阅与归还逻辑
Lending requires an ISBN or title to identify the book. The librarian enters the book identifier and a borrower ID. The system searches and, if the book exists and has Available > 0, decrements Available and records the transaction. Otherwise, an appropriate error message is shown.
借阅需要通过 ISBN 或书名来识别图书。图书管理员输入图书标识符和借阅者 ID。系统进行搜索,如果图书存在且 Available > 0,则递减 Available 并记录交易。否则,显示相应的错误消息。
Returning a book is the reverse: the librarian provides the book identifier, the system searches for it, increments Available, and optionally asks for confirmation before updating. The transaction log could be updated to mark the item as returned.
归还图书则相反:图书管理员提供图书标识符,系统搜索该图书,递增 Available,并可选择在更新前要求确认。交易日志可更新以标记该项目已归还。
Pseudocode for LendBook:
PROCEDURE LendBook(BookID, BorrowerID)
FOR i ← 1 TO BookCount
IF Books[i].ISBN = BookID OR Books[i].Title = BookID THEN
IF Books[i].Available > 0 THEN
Books[i].Available ← Books[i].Available - 1
LogTransaction(i, BorrowerID, "Lend")
OUTPUT "Book lent successfully"
RETURN
ELSE
OUTPUT "No copies available"
RETURN
ENDIF
ENDIF
NEXT i
OUTPUT "Book not found"
ENDPROCEDURE
The loop searches for the book by either ISBN or title. When found, it checks availability. If a copy is available, the counter is reduced and a log entry is written via a helper procedure. Early RETURN statements stop further processing.
循环通过 ISBN 或书名搜索图书。找到后,检查可借数量。如果有可用副本,计数器减少并通过辅助过程写入日志条目。RETURN 语句提前结束,不再继续处理。
7. User Interface and Menu Design | 用户界面与菜单设计
The main program loop will display a menu repeatedly until the user chooses to exit. A simple approach uses a CASE statement inside a REPEAT–UNTIL loop. Each option number maps to a procedure call.
主程序循环将反复显示菜单,直到用户选择退出。一个简单的方法是在 REPEAT–UNTIL 循环中使用 CASE 语句。每个选项编号对应一个过程调用。
REPEAT
OUTPUT "1. Add 2. Search 3. Lend 4. Return 5. List 6. Exit"
INPUT Choice
CASE Choice OF
1: CALL AddBook()
2: CALL SearchMenu()
3: CALL LendBook()
4: CALL ReturnBook()
5: CALL ListBooks()
6: OUTPUT "Goodbye"
OTHERWISE: OUTPUT "Invalid choice"
ENDCASE
UNTIL Choice = 6
The SearchMenu procedure can itself offer a sub‑menu for searching by title, ISBN or author, allowing the user to choose the most convenient search criterion. This keeps the code modular and user‑friendly.
SearchMenu 过程本身可以提供一个子菜单,用于按书名、ISBN 或作者进行搜索,让用户选择最方便的搜索条件。这使代码保持模块化且用户友好。
In addition, a short opening procedure, Initialise(), is called at the start of the program to load existing book records from a file into the array. A corresponding Finalise() procedure saves the data back to the file before the program ends.
此外,在程序开始时调用 Initialise() 过程,将现有的图书记录从文件加载到数组中。相应的 Finalise() 过程在程序结束前将数据保存回文件。
8. Testing Strategy and Test Data | 测试策略与测试数据
A thorough testing plan covers normal, abnormal and boundary cases. The table below summarises some key test scenarios. All tests will be carried out by running the program and observing the outputs.
一个全面的测试计划应涵盖正常、异常和边界情况。下表总结了一些关键的测试场景。所有测试通过运行程序并观察输出来执行。
| Test Case | 测试用例 | Input | 输入 | Expected Result | 预期结果 |
|---|---|---|
| Add a valid book | ISBN 978-3-16-148410-0, Title “Cambridge Computing”, Author “A. Student”, Year 2025, Copies 3 | Book added; Available copies = 3 |
| Add book with invalid year | Year = “abcd” | Error message; book not added |
| Search for existing title exactly | “Cambridge Computing” | Details displayed |
| Search for non‑existent title | “Unknown” | “No matching book found” |
| Lend a book with Available=1 | Valid book ID, valid borrower | Available becomes 0; success message |
| Lend when Available=0 (boundary) | Same book ID again | “No copies available” |
| Return a book that was lent | The book ID | Available increments by 1 |
Testing should also include data flow checks: after adding several books, the list‑all option must display all records correctly, and the file saved at exit must contain the updated information. Load the file again and check that the data persists.
测试还应包括数据流检查:添加多本书后,列表选项必须正确显示所有记录,并且退出时保存的文件必须包含更新后的信息。再次加载文件,检查数据是否持久保存。
9. Evaluation and Maintenance | 评估与维护
The linear search method, while simple, would become slow if the library catalogue grew to thousands of records. For a larger system, a binary search on a sorted array or a hash table might be more appropriate. The current array size limit of 1000 could be relaxed by using dynamic data structures such as a linked list or a file‑based database.
线性搜索方法虽然简单,但如果馆藏目录增长到数千条记录,则会变得缓慢。对于更大的系统,对已排序数组进行二分搜索或使用哈希表可能更为合适。当前 1000 条记录的数组大小限制可以通过使用动态数据结构(如链表)或基于文件的数据库来突破。
The case study demonstrates key AS‑level concepts: records, arrays, file handling, linear search, menus, and validation. Students learning this walkthrough should be able to adapt the design to other scenarios, such as a DVD rental store or a student registration system. Pay close attention to the pseudocode style, as CIE examiners expect consistent indentation and clear logic.
本案例展示了 AS 水平的关键概念:记录、数组、文件处理、线性搜索、菜单和验证。学习此演练的学生应能够将设计调整到其他场景,如 DVD 租赁店或学生注册系统。请密切注意伪代码风格,CIE 考官期望一致的缩进和清晰的逻辑。
Maintenance considerations include keeping the menu structure modular so that new features (e.g., fines for overdue books) can be added with minimal changes to existing code. Well‑named variables and comments are essential for readability, especially when the project is developed in stages or by a team.
可维护性考虑包括保持菜单结构的模块化,这样可以在对现有代码进行最少更改的情况下添加新功能(例如逾期罚款)。命名良好的变量和注释对于可读性至关重要,尤其是在分阶段或由团队开发项目时。
10. Conclusion and Exam Tips | 结论与应试技巧
This walkthrough illustrated the full case‑study cycle: from understanding requirements, to design, pseudocode, testing, and evaluation. In the AS exam, you may be asked to write pseudocode for a specific function, suggest test data with expected outcomes, or explain why a particular data structure was chosen.
本次演练展示了完整的案例分析周期:从理解需求到设计、伪代码、测试和评估。在 AS 考试中,你可能会被要求为特定功能编写伪代码、提出带有预期结果的测试数据,或解释为何选择某种特定的数据结构。
When answering case‑study questions, always justify your decisions: for example, state that you used an array because the number of books is small and fixed, and that a linear search is acceptable for a small dataset. Demonstrate validation and error handling in your pseudocode to earn marks for robustness.
在回答案例分析问题时,务必为你的决策提供理由:例如,说明你使用数组是因为图书数量少且固定,并且线性搜索对于小数据集是可接受的。在你的伪代码中展示验证和错误处理,以获得稳健性方面的分数。
Remember to structure your answers clearly, use the provided inserts or question spaces to sketch designs, and always refer to the specific scenario given. With consistent practice, the case‑study component can become one of the most rewarding parts of the AS Computer Science paper.
请记住,答案结构要清晰,利用提供的补充页或答题位置绘制设计草图,并始终结合给定的具体场景。通过持续练习,案例分析部分可以成为 AS 计算机科学试卷中最有收获的部分之一。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply