1 CS 106, Winter 2009 Class 5, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Introduction to C Programming
Introduction to C Programming
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
1 CS 106, Winter 2009 Class 10, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
1 CS 106, Winter 2009 Class 6, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
1 CS 106, Winter 2009 Class 19, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
1 CS 106, Winter 2009 Class 4, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
CS 201 Functions Debzani Deb.
The Fundamentals of C++ Basic programming elements and concepts JPC and JWD © 2002 McGraw-Hill, Inc.
Introduction to a Programming Environment
Modules, Hierarchy Charts, and Documentation
Chapter 1 Program Design
Introduction to C Programming
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Visual Basic Chapter 1 Mr. Wangler.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
CS0004: Introduction to Programming Variables – Numbers.
Introduction to Python
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
CS0004: Introduction to Programming Variables – Strings.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Page 1 Non-Payroll Cost Transfer Enhancements Last update January 24, 2008 What are the some of the new enhancements of the Non-Payroll Cost Transfer?
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Introduction to Programming with RAPTOR
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Applications Development
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 9, 2005 Lecture Number: 6.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
1 Writing Software Kashef Mughal. 2 Algorithms  The term algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem.  An Algorithm.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
SurveyDIG 2.1 Tutorial. Tutorial Contents Introduction Introduction Item Groups Item Groups –Creating new Groups –Naming Convention –Searching/Editing.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Visual Basic.NET Windows Programming
Whatcha doin'? Aims: To start using Python. To understand loops.
Variables, Expressions, and IO
Using Procedures and Exception Handling
Chapter 2 Visual Basic Interface
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
Introduction to Java, and DrJava part 1
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
VB Variables and Data
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Presentation transcript:

1 CS 106, Winter 2009 Class 5, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,

2 Creating a Specification Begin with developing use cases and tests. Identify what internal state the process will need to keep track of (requirements phase) List all the objects in the interface, and their events. Create a variable or other way of keeping track of internal state Create a flowchart for each event Go through the tests using the flowcharts to validate the specification

3 Implementation Once we have a good specification, the next step is implementation We will create VB projects to implement processes Running and testing the program will give an independent verification of our approach, plus we will have a working implementation of the process

4 VB Projects A VB project is more than just a single file of code VB has many great features that assist us in easily creating nice user interfaces that interact well with the Windows environment It automatically creates components that the operating system will need to run the program properly

5 VERY IMPORTANT!!! To be able to upload your project, you must create and save it in the proper way. The instructions are on the front page of the blackboard site. Read them before you start your first project, and follow them carefully. Be especially careful to follow the instructions for creating and saving your project.

6 Controls Controls are what VB calls the objects that can appear in the user interface Chapter 2.2 has a nice tutorial on the most common controls – Text box – Button – Label – List box

7 More controls We will also be interested in – Radio buttons – Check boxes – Timers There are plenty of other interesting ones (like menus) that we will look at if we have time

8 Let’s take a look… We are going to pause and take a look at the controls and how to work with them

9 Getting the code A zipped file containing a project like the one we just worked on is available on the blackboard site in the course contents area You can download it, right click, and use extract to unzip it Once it is unzipped you can open it. One way to do this is to open the controls.sln file and open the program from there

10 VB Code Editor Features Color codes keywords and comments (and text strings, as we’ll see later) Indents code nicely Has a completion feature that suggests allowable values Has context-sensitive help, lots of other nice features described in the book

11 Naming Controls Notice we have a naming convention for controls The name starts with a three-letter abbreviation for the type of control. For a button, it’s but. For a label lbl. For a timer, tmr. Etc. The rest of the name is descriptive of the use of the control. For example, butRed for the button that turns things red. In a longer name, capitalize each word. For example butRedWhiteBlue. Don’t be afraid to use long, descriptive names! They make your program much easier to use and understand.

12 Event Procedures To create an event procedure for a control, double click on it in the interface. The code will show up on the code page as an empty event procedure, which you can complete. For buttons, the event procedure will be invoked when the user clicks the button

13 Event Procedure Headers Each event procedure has a header that follows a standard format: Private SubbutGreen_Click(ByVal sender AsSystem.Object, ByValeAsSystem.EventArgs) HandlesbutGreen.Click The blue words are keywords reserved for use by the system For now we will ignore most of the contents of the header

14 Using Comments Each program must start with a comment including the name of the author, the author’s section number, and the date, followed by a brief overall description of the project Each procedure must be preceded by a descriptive comment Format: ‘************************************** ‘ Comment here. Use more lines if you need to. ‘**************************************

15 Text Box versus Label Use a text box when you want the user to enter some information, or the information in the box will be changed by the program Use a label for text that does not change during the execution of the program

16 Read the Book! There is a lot of information in the book, much of it of a rather detailed nature Read over it but don’t try to memorize it. You will learn the important things by using them a lot, and reading will give you a feeling for what is there so you can look it up when you need it Work some of the problems! Sit there at the computer with the book and try them. This is the best way to learn, even if you are not required to hand them in.

17 Break 10 minutes

18 Relating VB to Processes Our first step is to gather requirements by developing use cases and an interface design, and figuring out what internal state our process needs Once this is done, we can develop flow charts to specify the process Finally, we represent our objects by VB controls, and translate the event flow charts into code which can be tested using the tests

19 Internal State It’s reasonably clear how our objects and events will be represented in VB, but what about internal state? To represent any internal state the process needs to remember, we use variables Variables are containers for values. They are an abstract representation of computer memory

20 Physical Memory The physical memory in a computer is made up of tiny devices that have two distinct states These states are used to represent two values: 0 and 1 Each such value is called a bit The bits are grouped into “words” of 8, 16, or 32 bits (other values are also possible) Words are treated as a unit by parts of the hardware

21 Internal Representation One bit can have two values: 0 or 1 2 bits have 4 values: 00, 01, 10, 11 3 bits have 8 values: 000, 001, 010, 011, 100, 101, 110, 111 Each time you add a bit, you double the number of values that can be represented

22 Eight Bits With 8 bits you can represent 2 8 = 256 values It could be 256 characters (see Appendix A in the book) It could be 256 numbers, Or we might want some negative numbers, so it could be -127 to 128. These are all the same bit patterns: the key is how we interpret them

23 Using information When our program uses information, it has to know what kind of information it is: number, character, character string, etc When we name our variables, we also declare them, giving the name a type which describes the kind of information we are storing

24 Numbers There are several useful internal representations of numbers The number of values that can be represented depends on the number of bits used The range of values depends on the encoding We’ll use two main types: double and integer

25 Data Type Double The double type works on the same basis as scientific notation ( x ) Usually two words are used to store the mantissa ( ), hence the name double, and one word is used for the exponent (30) A number variable declared as double can hold very large or small numbers, but computations with it can lose accuracy DimaVarAs Double

26 Data Type Integer Integers are usually stored in one or two words depending on the implementation They are used when we need to count something Typical names are i, j, m, n, count They are always precise, but the range of values is much smaller than with Double Dimi, jas Integer

27 Numeric Operations Addition and subtraction: +, - Multiplication: * Versions of division: / (normal division), \ (integer division), mod (integer division remainder) Power: ^ where a^b means a b Built-in functions like Math.sqrt, Math.round, Int Parentheses can be used to change precedence, as in a*b +c versus a*(b+c)

28 Types of Results Adding two integers gives an integer, adding two doubles gives a double Dividing two integers using / gives a double! Which is why we have \ and mod: 14 \ 4 = 3, and 14 mod 4 = 2 The exponential function always gives a double as a result

29 Why??? … am I telling you these picayune details? Because there are times when having Integer or Double correct makes your program work, or not.