Student: Candidate Number: Assessor: Len Shand Herefordshire College of Technology Centre 24150 Edexcel BTEC Level 3 Extended Diploma in Information Technology (Assignment 1 of 3) Course: Unit: Title: Level 3 BTEC Nationals for IT Practitioners 15 Object Oriented Programming Assignment 1 - Features of Object Oriented Programming Internal Verification of assignment: Date: Outcome and Principal Objective(s): P1 explain the key features of object oriented programs P2 demonstrate the use of object oriented tools and techniques M1 explain the importance of encapsulation, polymorphism and inheritance on object oriented programming D1 evaluate the suitability of object oriented programs for graphical applications Overall Achievement (Fail/Pass/Merit/Distinction): Outcome P1 P2 M1 D1 Achieved Assessor's Comments: Hand out date: 17/09/2012 Due Date Submitted date Grade Assessor Verifier 1 12/10/2012 L. Shand 2 L. Shand 3 L. Shand I certify that this is my own work: 1
Pass Merit Distinction P1 explain the key features of event driven programs P2 demonstrate the use of object oriented tools and techniques M1 explain the importance of encapsulation, polymorphism and inheritance on object oriented programming D1 evaluate the suitability of object oriented programs for non-graphical applications P3 design an object oriented application to meet defined requirements P4 implement a working object oriented application to meet defined requirements P5 test an object oriented application P6 create on-screen help to assist the users of a computer program. M2 give reasons for the tools and techniques used in the production of an object oriented application M3 analyse actual test results against expected results to identify discrepancies M4 create technical documentation for the support and maintenance of a computer program. D2 evaluate an object oriented application. 2
Scenario While studying for your BTEC Nationals, you have been asked to provide some material for the college Wiki called All about programming. This resource aims to help people who want to learn programming and provides access to a wide range of information related to programming Tasks 1. The lead programmer has asked you to provide a short presentation that will explain the key features of object oriented programming. You must describe the features clearly and logically. Your presentation should be no more than 5 slides. You do not have to present your presentation. (P1) 2. Use an appropriate IDE to write the following program: a. Form: The form should look like the one in Figure 1. It is Form1.vb as shown in Figure 2. txtaccountnumber txtbalance txtamount radcheque radsavings radgeneral btngetbalance btnwithdraw Figure 1 Figure 2 3
b. Code listing for the Calculate button: Public Class frmteller Private Sub frmteller_load(byval sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub btngetbalance_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btngetbalance.click 'Dim oaccount As Account = New Account() Dim ochequeaccount As ChequeAccount = New ChequeAccount() Dim osavingsaccount As SavingsAccount = New SavingsAccount() Try If radcheque.checked Then txtbalance.text = ochequeaccount.newbalance(cint(txtaccountnumber.text)).tostring ElseIf radsavings.checked Then txtbalance.text = osavingsaccount.newbalance(cint(txtaccountnumber.text)).tostring 'ElseIf radgeneral.checked Then ' txtbalance.text = oaccount.getbalance(cint(txtaccountnumber.text)).tostring End If Catch eexception As Exception MsgBox(eException.Message) End Try End Sub Private Sub btnwithdraw_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnwithdraw.click Dim osavingsaccount As SavingsAccount = New SavingsAccount() Try txtbalance.text = osavingsaccount.withdraw(cint(txtaccountnumber.text), CDbl(txtAmount.Text)).ToString Catch eexception As Exception MsgBox(eException.Message) End Try End Sub 4
c. As shown in Figure 2, you will need to add three classes called: i. Account.vb ii. ChequeAccount.vb iii. SavingsAccount.vb d. The code for Account.vb is as follows: Public MustInherit Class Account Private intaccountnumber As Integer Private dblbalance As Double Protected Function GetBalance(ByVal AccountNumber As Integer) As Double intaccountnumber = AccountNumber 'Data normally retrieved from database. Hardcoded for demo only If intaccountnumber = 1 Then Return 1000 ElseIf intaccountnumber = 2 Then Return 2000 Else Throw New Exception("Account number incorrect.") End If End Function 'Withdraw method Public Function Withdraw(ByVal AccountNumber As Integer, ByVal Amount As Double) As Double dblbalance = GetBalance(AccountNumber) If dblbalance >= Amount Then dblbalance -= Amount Return dblbalance Else Throw New Exception("Not enough funds.") End If End Function Public Function newbalance(byval AccountNumber As Integer) As Double dblbalance = GetBalance(AccountNUmber) Return dblbalance End Function e. The code for SavingsAccount.vb is as follows: Public Class savingsaccount Inherits Account f. The code for ChequeAccount.vb is as follows: Public Class ChequeAccount Inherits Account g. Using the above program, explain what tools and techniques you used to write this object oriented program. Take into account things like functions, IDE, types of variables (ie global, local, static, overloads and instances) (P2) 5
3. Using your program in Task 2 and other resources explain the following terms and explain why they are important: a. Encapsulation b. Polymorphism c. Inheritance You can make use of a presentation or a short website to explain these features. (M1) 4. Looking at the program you wrote in Task 2, evaluate the suitability of object oriented programs for graphical applications. A short report of not more than 300 words will be sufficient for this task. (D1) 6