Professional Documents
Culture Documents
ASSIGNMENT2-2024
ASSIGNMENT2-2024
Name Waqas
Registration ID 51203
Course Formal Method in Software
Instructor Atiya Masood
ASSIGNMENT # 02
Question # 01[5]
Read the attached paper with this assignment on Z specification and write a brief introduction
(200-300 words) about Z, highlighting its key features and benefits for creating schemas.
Z's formality allows one to explicitly specify and reason about the behavior of a system. This
helps developers find inconsistencies, ambiguities, or incompleteness early on, which
minimizes errors in the final product. It's also important to keep in mind that formal
techniques, such validation processes, can be used for verification due to its accuracy and
ensure that the system conforms with the specifications.
Abstraction is another important benefit of using Z. Z lets engineers talk about high-level
aspects of the system without getting into implementation details. Stakeholder
communication has improved as a result, and there is a solid foundation for the development
and testing phases to follow.
Page 1 of 3
FACULTY OF ENGINEERING, SCIENCES AND TECHNOLOGY
Question # 02[5]
Write Java code that corresponds to an example from a Z schema given in a research paper.
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Page 2 of 3
FACULTY OF ENGINEERING, SCIENCES AND TECHNOLOGY
// Adding students
System.out.println(system.addStudent("Alice", "R001")); // true
System.out.println(system.addStudent("Bob", "R002")); // true
System.out.println(system.addStudent("Alice", "R003")); // false, Alice already exists
System.out.println(system.addStudent("Charlie", "R001")); // false, R001 is already
taken
// Removing students
System.out.println(system.removeStudent("Alice")); // true
System.out.println(system.removeStudent("Alice")); // false, Alice does not exist
anymore
Page 3 of 3