












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Assignment 2 for Advanced Programming 1651
Typology: Assignments
1 / 20
This page cannot be seen from the preview
Don't miss anything!













Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 20: Advanced Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name PHAN MINH TRI Student ID GCD Class GCD0904 Assessor name PHAM THANH SON Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P3 P4 M3 M4 D3 D
Grade: Assessor Signature: Date: Lecturer Signature:
Table of Figures Figure 1: Class Diagram ................................................................................................................................................. 5 Figure 2: Interface IInformation .................................................................................................................................... 5 Figure 3: Car Class ......................................................................................................................................................... 6 Figure 4: ElectricCar Class.............................................................................................................................................. 6 Figure 5: Store Class ...................................................................................................................................................... 7 Figure 6: Singleton pattern structure .......................................................................................................................... 14 Figure 7: Factory pattern structure ............................................................................................................................. 15 Figure 8: Decorator pattern structure ......................................................................................................................... 16 Figure 9: Adapter pattern structure ............................................................................................................................ 17 Figure 10: Command pattern structure ...................................................................................................................... 18 Figure 11: Iterator pattern structure........................................................................................................................... 19
❖ The preceding report covered everything relevant to OOP, including OOP theories, OOP characteristics, etc. In addition, a basic introduction to UML and class connections was presented. ❖ To put that information into reality, I will choose a specific scenario to apply to apply program to in this report. The UML class diagram will be provided in the report to aid comprehension. Finally, in future projects, a brief introduction to the design pattern will be employed.
I. Scenario ❖ My friend just requested me to assist them with a car management program for their store. I'm planning to create an app that will save the list of cars in the store. This software enables users to add new cars by inputting car information such as ID, Brand, Model, and Price. Furthermore, the program allows you to search for cars by brand or model, delete cars from the list, and update car information based on the car's ID.
II. Class Diagram ❖ This is class diagram of Car Management program, including 4 classes: Car (Parent class), ElectricCar (Children class), IInformation (Interface) and Store class which contains CRUD functions Figure 1 : Class Diagram
all cars by their brand, FindCarbyModel() for searching specific car by its model, RemoveCarbyModel() for deleting car in list by its model which user enter and UpdateCarbyID() for editing information of car by its id which user input into program. Figure 5 : Store Class
I. Code
❖ In this interface, it just implementation the function PrintInformation() for other class inherits and build their login on it function.
❖ Fields includes id, brand, model, and price according to the diagram ❖ Properties of these fields to encapsulate and set the way to access to fields ❖ Constructor of the Car class which generate all values of cars by the properties which covered before ❖ Function PrintInformation() to print information of cars
❖ RemoveCar() Function: this function is used for deleting car in the list which has the same model which the model the user input to the program ❖ PrintInformation() Function: this function, which inherits from IInformation interface, is used for print all cars in the list to the screen ❖ FindCarbyModel() Function: this function is used for searching specific car by the model which user has enter to the program, is equals to the first one the cars list
❖ FindCarbyBrand() Function: this function is used for searching all cars of the brand which equals to the brand user input to the program II. Program Screenshots ❖ Interface of the program ❖ AddCar Function
❖ UpdateCarbyId() Function:
I. Creational patterns
❖ The singleton design pattern ensures that a class has only one instance while offering a global access point to this instance. ❖ The Singleton pattern handles two issues at once, therefore breaching the Single Responsibility Principle:
II. Structural patterns
❖ Decorator is a structural design pattern that allows you to add new behaviors to objects by wrapping them in special wrapper objects that contain the behaviors. ❖ Structure Figure 8 : Decorator pattern structure
❖ The adapter design pattern allows items with mismatched interfaces to interact. ❖ You can make an adaptor. This is a special object that transforms the interface of one object so that another object may comprehend it. An adaptor encircles one of the items to conceal the complexities of conversion occurring behind the scenes. The wrapped object is completely unaware of the adaptor. ❖ Adapters may enable objects with different interfaces communicate by converting data into other representations. The following is how it works:
❖ Iterator is a behavioral design pattern that allows you to explore collection components without releasing their underlying representation (list, stack, tree, etc.). ❖ Structure Figure 11 : Iterator pattern structure
Dofactory, 2022. C# Iterator. [Online] Available at: https://www.dofactory.com/net/iterator-design-pattern [Accessed 1 July 2022]. Refactoring, 2022. DESIGN. [Online] Available at: https://refactoring.guru/design-patterns [Accessed 1 July 2022].