FDSc in ICT. Building a Program in C#

Similar documents
Herefordshire College of Technology Centre Edexcel BTEC Level 3 Extended Diploma in Information Technology (Assignment 1 of 3)

CALCULATOR APPLICATION

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

CSIS 1624 CLASS TEST 6

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Last lecture. Lecture 9. in a nutshell. in a nutshell 2. Example of encapsulation. Example of encapsulation. Class test. Procedural Programming

IBSDK Quick Start Tutorial for C# 2010

public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;

Visual Studio Windows Form Application #1 Basic Form Properties

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

Encapsulation. Mason Vail Boise State University Computer Science

Representing Recursive Relationships Using REP++ TreeView

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent() call. //

Object oriented lab /second year / review/lecturer: yasmin maki

Evaluation Copy. C# Essentials. Student Guide Revision 4.5. Object Innovations Course 4102

BloomBank Financial Software Design

Visual Basic/C# Programming (330)

Object-oriented basics. Object Class vs object Inheritance Overloading Interface

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

You can call the project anything you like I will be calling this one project slide show.

Software Design and Analysis for Engineers

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Chapter 2. Ans. C (p. 55) 2. Which is not a control you can find in the Toolbox? A. Label B. PictureBox C. Properties Window D.

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

UNIT-3. Prepared by R.VINODINI 1

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Create your own Meme Maker in C#

Your First Windows Form

Start Visual Studio, create a new project called Helicopter Game and press OK

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Visual Basic/C# Programming (330)

Activating AspxCodeGen 4.0

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [

Storing Data in Objects

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2)

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

Click on the empty form and apply the following options to the properties Windows.

Class Test 5. Create a simple paint program that conforms to the following requirements.

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

Form Properties Window

Mutating Object State and Implementing Equality

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

Lab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

Understanding Events in C#

JUnit Testing Framework Architecture

In-Class Worksheet #4

Lecture 27. Log into Windows/ACENET. Start MS VS and open the PointClassDemo project. Reminder: Project 1 is due on Wednesday. Questions?

C# Programming for Developers Course Labs Contents

Lecture 8 Building an MDI Application

Problem description: After finishing the lab, the student will practice:

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

// Precondition: None // Postcondition: The address' name has been set to the // specified value set;

Quick Guide for the ServoWorks.NET API 2010/7/13

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

CSCD 330 Network Programming

II. Programming Technologies

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

C C C C++ 2 ( ) C C++ 4 C C

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

visual studio vs#d express windows desktop

Eduardo M. Breijo Baullosa May 2, Assignment 17. Report

Lecture 21: Concurrency in Other Environments (Part 2)

CSCD 330 Network Programming

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

EXAMINATIONS 2012 END-OF-YEAR SWEN222. Software Design. Question Topic Marks 1. Design Quality Design Patterns Design by Contract 12

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

Student Guide Revision 1.0

EL-USB-RT API Guide V1.0

int main() { int account = 100; // Pretend we have $100 in our account int withdrawal;

Today. Homework. Lecture Notes CPSC 224 (Spring 2012) Quiz 5. interfaces. exceptions. best practices. start on swing (if time) hw3 due

Writing Your First Autodesk Revit Model Review Plug-In

Визуал програмчлал. Багш: Ж. Шинэбаяр /Маг/

Classes and Methods: Classes

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism

Engr 123 Spring 2018 Notes on Visual Studio

Chapter 6. Multiform Projects The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

C# winforms gridview

Object oriented programming

LISTING PROGRAM. //Find the maximum and minimum values in the array int maxvalue = integers[0]; //start with first element int minvalue = integers[0];

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

CSE 332: Locks and Deadlocks. Richard Anderson, Steve Seitz Winter 2014

เว บแอพล เคช น. private void Back_Click(object sender, EventArgs e) { this.webbrowser2.goback(); }

INFORMATICS LABORATORY WORK #2

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Unit 1 Workbook ICS3U

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Implementation. (Mapping to Java) Jörg Kienzle & Alfred Strohmeier. COMP-533 Implementation

Diving into Visual Studio 2015 (Day #5): Debugging Improvements in Visual Studio 2015 (Part 1) -Akhil Mittal

CS159. Nathan Sprague

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

Online Activity: Debugging and Error Handling

Visual Studio.NET.NET Framework. Web Services Web Forms Windows Forms. Data and XML classes. Framework Base Classes. Common Language Runtime

Transcription:

FDSc in ICT Building a Program in C#

Objectives To build a complete application in C# from scratch Make a banking app Make use of: Methods/Functions Classes Inheritance

Scenario We have a bank that has accounts. Cheque accounts Savings accounts We need a teller to make withdrawals and retrieve balances The teller must update the balance when a withdrawal is made

Lets Look at This... How many classes do we need? What is the user in this scenario Who does what?

Create a New Project Create a new project in VS called Banking Rename Form1.cs to frmteller.cs Change the text of the form to Teller

The Interface Form: frmteller Text: Teller Label1: Account Number: Label2: Balance: Label3: Amount: textbox1: txtaccountnumber textbox2: txtbalance textbox3: txtamount radiobutton1: radcheque radiobutton2: radsavings button1: btngetbalance button2: btnwithdraw

Lets Look at This... Can you work out from the form who does what? What of your previous decisions will be acted out by each event?

Add Classes Right click on the bold letters of Banking Click on Add then on class Rename it to Account.cs Similarly, create 2 more classes called ChequeAccount.cs and SavingsAccount.cs

Account.cs The Account class needs to be able to give the balance [GetBalance()] It also needs to determine which account is being used (savings or cheque) It also needs to determine the account number It needs to have a withdrawal function/method [Withdraw()]

After Account.cs is Created using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Banking class Account

public int intaccountnumber; public double dblbalance; //We will have a function/method here to check the account number and get the balance //We need a withdraw method //We need a new balance method

The GetBalance() Method protected double GetBalance(int AccountNumber) intaccountnumber = AccountNumber; //Data normally retrieved from database. Hardcoded for demo only if (intaccountnumber == 1) return 1000; else if (intaccountnumber == 2) return 2000; else throw new Exception("Account number incorrect.");

The Withdraw() Method public double Withdraw(int AccountNumber, double Amount) dblbalance = GetBalance(AccountNumber); if (dblbalance >= Amount) dblbalance -= Amount; return dblbalance; else throw new Exception("Not enough funds.");

The NewBalance() Method public double newbalance(int AccountNumber) dblbalance = GetBalance(AccountNumber); return dblbalance;

Make Savings Class Inherit class SavingsAccount : Account

Make Cheque Class Inherit class ChequeAccount : Account

The Form We will need an If statement to differentiate between which radio button has been clicked

Lets Populate the GetBalance Button Double click on the GetBalance button private void btngetbalance_click(object sender, EventArgs e)

Right after the InitializeComponent(); brace, add //Create new accounts ChequeAccount ochequeaccount = new ChequeAccount(); SavingsAccount osavingsaccount = new SavingsAccount();

Add the following in the button event: private void btngetbalance_click(object sender, EventArgs e) //Check which radio button has been selected (or not) try if (radcheque.checked) txtbalance.text = ochequeaccount.newbalance(convert.toint32(txtaccountnumber.text)).tostring(); else if (radsavings.checked) txtbalance.text = osavingsaccount.newbalance(convert.toint32(txtaccountnumber.text)).tostring(); catch (Exception eexception) MessageBox.Show(eException.Message);

Lets Populate the Withdraw Button Double Click the Withdraw button private void btnwithdraw_click(object sender, EventArgs e)

try txtbalance.text = osavingsaccount.withdraw(convert.toint32(txtaccou ntnumber.text), Convert.ToDouble(txtAmount.Text)).ToString(); catch (Exception eexception) MessageBox.Show(eException.Message);

Add a Program Entry Point Create a new class called program.cs After the [STATREAD] add: static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmteller());

Run your App