Docsity

1651_Advanced Programming_Assignment 2, Assignments of Advanced Computer Programming

Toggle sidebar
bg1
ASSIGNMENT 2 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 20: Advanced Programming
Submission date 7/1/2022 Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Mai Tran Tuan Anh Student ID GCD201452
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 D4
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43

Partial preview of the text

Download 1651_Advanced Programming_Assignment 2 and more Assignments Advanced Computer Programming in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 20: Advanced Programming

Submission date 7/1/2022 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Mai Tran Tuan Anh 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

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • I. BUILD AN APPLICATION DERIVED FROM UML CLASS DIAGRAM (P3).......................................................................................................................
      1. UML.....................................................................................................................................................................................................................
      1. Interface IInformation..........................................................................................................................................................................................
      1. Class Book............................................................................................................................................................................................................
      1. Class People.......................................................................................................................................................................................................
      1. Class Hired.........................................................................................................................................................................................................
      1. Class Employee..................................................................................................................................................................................................
      1. Class Customer...................................................................................................................................................................................................
      1. Class Action........................................................................................................................................................................................................
      1. Class Batch.........................................................................................................................................................................................................
      1. Main program....................................................................................................................................................................................................
  • II. CODE IMPLEMENTATION.......................................................................................................................................................................................
  • III. DISCUSS A RANGE OF DESIGN PATTERNS WITH RELEVANT EXAMPLES OF CREATIONAL, STRUCURAL AND BEHAVIORAL PATTERN TYPES.........
      1. Definition...........................................................................................................................................................................................................
      1. Creational pattern..............................................................................................................................................................................................
    • 2.1 Factory Method...............................................................................................................................................................................................
    • 2.2 Abstract factory...............................................................................................................................................................................................
      1. Structural pattern...............................................................................................................................................................................................
    • 3.1 Bridge...............................................................................................................................................................................................................
    • 3.2 Façade..............................................................................................................................................................................................................
      1. Behavior pattern................................................................................................................................................................................................
    • 4.1 Template method............................................................................................................................................................................................
    • 4.2 State.................................................................................................................................................................................................................
  • III. Bibliography..........................................................................................................................................................................................................
  • Figure 1: Application UML............................................................................................................................................................................................
  • Figure 2: Interface IInformation...................................................................................................................................................................................
  • Figure 3: Class Book (1)..............................................................................................................................................................................................
  • Figure 4: Class Book (2)..............................................................................................................................................................................................
  • Figure 5: Class Customer............................................................................................................................................................................................
  • Figure 6: Class Hired..................................................................................................................................................................................................
  • Figure 7: Class Employees..........................................................................................................................................................................................
  • Figure 8: Class Actions (1)..........................................................................................................................................................................................
  • Figure 9: Class Actions (2)..........................................................................................................................................................................................
  • Figure 10: Function to print out the menu.................................................................................................................................................................
  • Figure 11: Create 4 lists.............................................................................................................................................................................................
  • Figure 12: Constructor of class Batch.........................................................................................................................................................................
  • Figure 13: Function add book and customer.............................................................................................................................................................
  • Figure 14: Function to display information (1)...........................................................................................................................................................
  • Figure 15: Function to display information (2)...........................................................................................................................................................
  • Figure 16: Function to find book by name or ID.........................................................................................................................................................
  • Figure 17: Function sort book by genre.....................................................................................................................................................................
  • Figure 18: Function sort book by author....................................................................................................................................................................
  • Figure 19: Function edit book by ID...........................................................................................................................................................................
  • Figure 20: Function remove book by ID.....................................................................................................................................................................
  • Figure 21: Function hire book....................................................................................................................................................................................
  • Figure 22: Main program (1)......................................................................................................................................................................................
  • Figure 23: Main program (2)......................................................................................................................................................................................
  • Figure 24: Main program (3)......................................................................................................................................................................................
  • Figure 25: Application main menu.............................................................................................................................................................................
  • Figure 26: Display book information..........................................................................................................................................................................
  • Figure 27: Display customer information...................................................................................................................................................................
  • Figure 28: Display employee information..................................................................................................................................................................
  • Figure 29: Add new book...........................................................................................................................................................................................
  • Figure 30: List book after added................................................................................................................................................................................
  • Figure 31: Add new customer....................................................................................................................................................................................
  • Figure 32: List customer after added.........................................................................................................................................................................
  • Figure 33: Find book by name....................................................................................................................................................................................
  • Figure 34: No book matched with input....................................................................................................................................................................
  • Figure 35: Find book by ID.........................................................................................................................................................................................
  • Figure 36: No book matched with input....................................................................................................................................................................
  • Figure 37: Sort book by genre....................................................................................................................................................................................
  • Figure 38: No book matched with input....................................................................................................................................................................
  • Figure 39: Sort book by author..................................................................................................................................................................................
  • Figure 40: No book matched with input....................................................................................................................................................................
  • Figure 41: No book matched with input....................................................................................................................................................................
  • Figure 42: Edit book by ID..........................................................................................................................................................................................
  • Figure 43: List book before editing............................................................................................................................................................................
  • Figure 44: List book after editing...............................................................................................................................................................................
  • Figure 45: No book matched with input....................................................................................................................................................................
  • Figure 46: Delete success...........................................................................................................................................................................................
  • Figure 47: List book before deleting..........................................................................................................................................................................
  • Figure 48: List book after deleting.............................................................................................................................................................................
  • Figure 49: Quantity of book <= 0...............................................................................................................................................................................
  • Figure 50: Hire successfully........................................................................................................................................................................................
  • Figure 51: Hired list....................................................................................................................................................................................................
  • Figure 52: New customer has been added to list.......................................................................................................................................................
  • Figure 53: Quantity of books before hiring................................................................................................................................................................
  • Figure 54: Quantity of books after hiring...................................................................................................................................................................
  • Figure 55: Design pattern...........................................................................................................................................................................................
  • Figure 56: Types of creational pattern.......................................................................................................................................................................
  • Figure 57: Factory method structure.........................................................................................................................................................................
  • Figure 58: Abstract factory structure.........................................................................................................................................................................
  • Figure 59: Bridge pattern structure...........................................................................................................................................................................
  • Figure 60: Facade structure.......................................................................................................................................................................................
  • Figure 61: Template structure...................................................................................................................................................................................
  • Figure 62: State structure..........................................................................................................................................................................................

I. BUILD AN APPLICATION DERIVED FROM UML CLASS DIAGRAM (P3)

1. UML

  • As the scenario is discussed in the previous reports, I will have to design an application to take control over the library of the

city. Basically, the application will have 6 different classes and 1 interface as below.

Figure 1 : Application UML

Figure 3 : Class Book (1) Figure 4 : Class Book (2)

4. Class People

  • People class contained all properties of a People such as name, age and phone number. I also declared 2 constructors so that I

can create a new object from this class. Class People is also a subclass of interface IInformation, so it can use the function of the

interface. Function displayInformation() will be inherited, override and changed so that it can be used to display information

of the people. This class is declared so that class Customer and Employee can inherit all properties from this class

Figure 5 : Class People

6. Class Employee

  • This class is declared to contain information of library’s employees. I make it to inherit from People so that it will have all

properties of a people. Beside. I create an additional property, which is ID and declared it as integer. It will have a constructor

in order to create new object and also a function to display employees’ information

Figure 7 : Class Employees

7. Class Customer

  • Class Customer is used to store customer information. As I have mentioned before, class Customer will inherit all properties

from class People, including name, age and phone. It will also inherit function to display customer information

Figure 8 : Class Customer

Figure 10 : Class Actions (2)

Figure 11 : Function to print out the menu

9. Class Batch

  • Base on all small functions that are declared in class Actions, all of them will be use again in this class and built into large

functions of each options display on the screen. First, it will declare 4 different list for each type of objects

Figure 12 : Create 4 lists

  • First, I need to create function to add book and customer into the system. These functions are pretty similar. At first, the user

needs to insert total number of book or customer they want to insert. Then, a for loop will be executed, data of each book and

customer will be read by the application and add them into the list.

Figure 14 : Function add book and customer

  • Next are functions to display information of the library, including book, employee, customer and hired information. All of

them have the same flow. The for loop run from the first index of the list until the last one, and for each objects saved inside

the lists, a function to display information will be used and the information of them will be displayed on the screen

Figure 15 : Function to display information (1)