Docsity

Programming - Assignment 2 - 1618 - Grade D, Assignments of Computer Programming

Toggle sidebar
bg1
ASSIGNMENT 2 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 1: Programming
Submission date 8/29/2022 Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Student ID
Class Assessor name
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
P2 P3 P4 P5 M2 M3 M4 D2 D3 D4
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

Partial preview of the text

Download Programming - Assignment 2 - 1618 - Grade D and more Assignments Computer Programming in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date 8/29/2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Student ID Class Assessor name 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 P2 P3 P4 P5 M2 M3 M4 D2 D3 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

I. Task 1 – Introduction to your program (P3) I use Library Management System scenario to demonstrate on Visual studio Library Management System A software for online movie ticket booking system facilitates the purchasing of movie tickets to its customers. It allows the customers to browse through available movies and book seats, the admin to check the for the booking information.

  1. User requirements
    1. Each cinema can have multiple halls and each hall can run one movie show at a time.
    2. Each Movie will have multiple shows.
    3. Customers should be able to search movies by their title, language, genre, release date, and city name.
    4. The customer should be able to select a show at a particular cinema and book their tickets.
  2. Explain application There are two main users are customer and admin. Customer: able to search movies by their title, language, genre, release date, and city name and select a show at a particular cinema and book their tickets. After booking ticket, they are allowed to cancel booking. Admin: Who can add movies, update movie, remove movies and check booking information.

Task 2 – Explain programming

  1. Procedural programming a. Definition Procedural Programming may be the first programming paradigm that a new developer will learn. Fundamentally, the procedural code is the one that directly instructs a device on how to finish a task in logical steps. This paradigm uses a linear top-down approach and treats data and procedures as two different entities. Based on the concept of a procedure call, Procedural Programming divides the program into procedures, which are also known as routines or functions, simply containing a series of steps to be carried out. Simply put, Procedural Programming involves writing down a list of instructions to tell the computer what it should do step-by-step to finish the task at hand. b. Key features  Predefined functions: A predefined function is typically an instruction identified by a name. Usually, the predefined functions are built into higher-level programming languages, but they are derived from the library or the registry, rather than the program. One example of a pre-defined function is ‘charAt()’, which searches for a character position in a string.
  1. Object-Oriented Programming (OOP) a. Definition OOP is an approach to programming which recognizes life as we know it as a collection of objects, which work in tandem with each other to solve a particular problem at hand. The primary thing to know about OOP is encapsulation, which is the idea that each object which holds the program is self-sustainable, which means that all the components that make up the object are within the object itself. Now since each module within this paradigm is self-sustainable, objects can be taken from one program and used to resolve another problem at hand with little or no alterations. b. Key features Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects. It is used to structure a software program into simple, reusable pieces of code blueprints (usually called classes), which are used to create individual instances of objects. Classes can also contain functions, called methods available only to objects of that type. These functions are defined within the class and perform some action helpful to that specific type of object.

class Parrot: pass obj = Parrot() class obj (^) Parrot Class A class is a blueprint for the object. We can think of class as a sketch of a parrot with labels. It contains all the details about the name, colors, size etc. Based on these descriptions, we can study about the parrot. Here, a parrot is an object. The example for class of parrot can be : Here, we use the keyword to define an empty class Parrot. From class, we construct instances. An instance is a specific object created from a particular class. Object An object (instance) is an instantiation of a class. When class is defined, only the description for the object is defined. Therefore, no memory or storage is allocated. The example for object of parrot class can be: Here, is an object of class Four Principles of OOP The four pillars of object-oriented programming are:  Inheritance: child classes inherit data and behaviors from parent class  Encapsulation: containing information in an object, exposing only selected information  Abstraction: only exposing high level public methods for accessing an object  Polymorphism: many methods can do the same task Inheritance Inheritance allows classes to inherit features of other classes. Put another way, parent classes extend attributes and behaviors to child classes. Inheritance supports reusability.

Notice that the HerdingDog class does not have a copy of the showInfo() method, it inherits the showInfo() method defined in the parent Dog class. When the code calls hDog.showInfo() method, the showInfo() method walks up the chain of child to parent classes, to find where the showInfo method is defined. Encapsulation Encapsulation means containing all important information inside an object, and only exposing selected information to the outside world. Attributes and behaviors are defined by code inside the class template. Then, when an object is instantiated from the class, the data and methods are encapsulated in that object. Encapsulation hides the internal software code implementation inside a class, and hides internal data of inside objects. Encapsulation requires defining some fields as private and some as public.  Private / Internal interface: methods and properties, accessible from other methods of the same class.  Public / External Interface: methods and properties, accessible also from outside the class. Encapsulation adds security. Attributes and methods can be set to private, so they can’t be accessed outside the class. To get information about data in an object, public methods & properties are used to access or update data. This adds a layer of security, where the developer chooses what data can be seen on an object by exposing that data through public methods in the class definition. Within classes, most programming languages have public, protected, and private sections. Public is the limited selection of methods available to the outside world, or other classes within the program. Protected is only accessible to child classes. Private code can only be accessed from within that class. To go back to our dog/owner example, encapsulation is ideal so owners can’t access private information about other people’s dogs.

Consider the getName(), getAge() methods in our example code, Attributes are hidden inside the Dog class. The hDog object uses the getName() and getAge() method to return the object information. Abstraction Abstraction means that the user interacts with only selected attributes and methods of an object. Abstraction uses simplified, high level tools, to access a complex object.  Using simple things to represent complexity  Hide complex details from user Abstraction is using simple classes to represent complexity. Abstraction is an extension of encapsulation. For example, you don’t have to know all the details of how the engine works to drive a car. A driver only uses a small selection of tools: like gas pedal, brake, steering wheel, blinker. The engineering is hidden from the driver. To make a car work, a lot of pieces have to work under the hood, but exposing that information to the driver would be a dangerous distraction.

  1. Event-driven programming Software that is event-driven response primarily to user events or other comparable input. The notion of even-driven programming has inspired the rise of event handles and other resources in application development and other types of programming. Even-driven software is also known as an event-driven application.

In a typical even-driven application, there is a main loop that listens for even and then calls an callback function when one is detected. Instead of a continually running main loop, hardware interrupts can be used in embedded systems to accomplish the same result. Event-driven applications may be developed in any programming language, however, languages with high-level abstractions, such as to await and closures, make the work simpler.

Task 3 – IDE features (P4 – M2 – M3 – M4)

  1. Introduction about IDE Integrated development environments (IDE) are applications that facilitates the development of other applications. Designed to encompass all programming tasks in one application, one of the main benefits of an IDE is that they offer a central interface with all the tools a developer needs, including:  Code editor: Designed for writing and editing source code, these editors are distinguished from text editors because work to either simplify or enhance the process of writing and editing of code for developers  Compiler: Compilers transform source code that is written in a human readable/writable language in a form that computers can execute.  Debugger: Debuggers are used during testing and can help developers debug their application programs.  Build automation tools: These can help automate developer tasks that are more common to save time. In addition, some IDEs may also include:  Class browser: Used to study and reference properties of an object-oriented class hierarchy.  Object browser: Used to inspect objects instantiated in a running application program.  Class hierarchy diagram: Allows developers to visualize the structure of object-oriented programming code. The IDE may be a stand-alone application, though it might also be included as part of one or more compatible applications. There are some IDE that highly recommend for coding such as Microsoft Visual Studio, PhpStorm, IntelliJ IDEA, Eclipse…

modules are tightly coupled, debugging becomes harder as any change in one module may cause more bugs to appear in another. Sometimes it takes more time to debug a program than to code it. b. The debugging process  Problem identification and report preparation.  Assigning the report to the software engineer to the defect to verify that it is genuine.  Defect Analysis using modeling, documentation, finding and testing candidate flaws, etc.  Defect Resolution by making required changes to the system.  Validation of corrections. The debugging process will always have one of two outcomes :

  1. The cause will be found and corrected.
  2. The cause will not be found. Later, the person performing debugging may suspect a cause, design a test case to help validate that suspicion and work toward error correction in an iterative fashion. During debugging, we encounter errors that range from mildly annoying to catastrophic. As the consequences of an error increase, the amount of pressure to find the cause also increases. Often, pressure sometimes forces a software developer to fix one error and at the same time introduce two more. c. Debug in Visual Studio IDE First, in order to run Debug in Visual Studio IDE, we need to create a breakpoint by putting the pointer in a position Which we need to create break point or select Debug on the toolbar and select the Toggle Breakpoint function (F9). Then Press F5 (Debug > Start Debugging) or the Start Debugging button Start Debugging in the Debug Toolbar. When fixing bugs, Debug run to the breakpoint and the debugging process will end Create breakpoint

Press Start Debugging (F5) Some basic functions to use: Step into (F11) (Debug > Step Into is the Step Into command and advances the app execution one statement at a time. When you start the app with F11, the debugger breaks on the first statement that gets executed. Step Over(F10): Run passes through each function in the code, but does not stop inside each method After debugging, if you want to exit this function, select Stop Debugging (Shift + F5) on the toolbar or select Debug on the toolbar and select Stop Debugging

Inside file Cinema.cs I declared two class Movie and HideShow with a similar variable. The only thing different between them is class HideShow does not have array string of show in order to display the class information on the data grid view. Both class serve a similar purpose is to store the movie information and display them later. The HideShow class does not have array string show In file form MovieBooking I create function DisplayDGV to transfer any class List into Data Grid View and show the stored information to the user.

The function takes class list pass through the parameter and display in Data Grid View I created two sort function with a similar solution, one for sorting by Titles in the list by alphabet and the other is for sorting by City Names. Both of them pass class list through parameter and execute them.