Visual Programming Lecture 4.

Slides:



Advertisements
Similar presentations
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 10: Continuing with classes Constructors, using classes.
Advertisements

What have we learned so far… Preprocessor directives Introduction to C++ Variable Declaration Display Messages on Screen Get Information from User Performed.
OOP / VB.NET (Chp4) DR. JOHN ABRAHAM UTPA Credit: Partial slides from startvbdotnet.com.
 2009 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter3: Introduction to Classes and Objects 1.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes and Objects Systems Programming.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 3rd Edition.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
Java: How to Program Methods Summary Yingcai Xiao.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Classes and Objects. 2 Outlines Class Definitions and Objects Member Functions Data Members –Get and Set functions –Constructors.
 2009 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Introduction to Classes and Objects (Through Ch 5) Dr. John P. Abraham Professor UTPA.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 01] Introduction to.
1.  A method describes the internal mechanisms that actually perform its tasks  A class is used to house (among other things) a method ◦ A class that.
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Fall 2012 Lecture 8: File I/O; Introduction to classes.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
CSCI 3327 Visual Basic Chapter 3: Classes and Objects UTPA – Fall 2011.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
Chapter 3 (B) 3.5 – 3.7.  Variables declared in a function definition’s body are known as local variables and can be used only from the line of their.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 9: Continuing with classes.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Classes Methods and Properties. Introduction to Classes and Objects In object-oriented programming terminology, a class is defined as a kind of programmer-defined.
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Jozef Goetz,  2014 Pearson Education, Inc. All rights reserved.  2002 Prentice Hall. All rights reserved. expanded by J. Goetz, 2015 credits:
A DVANCED P ROGRAMMING C HAPTER 4: I NTRODUCTION TO I NTRODUCTION TO C LASSES, O BJECTS, M ETHODS AND STRINGS Dr Shahriar Bijani Winter 2016.
Topics Instance variables, set and get methods Encapsulation
A DVANCED P ROGRAMMING C HAPTER 5 & 6: C ONTROL S TRUCTURES Dr Shahriar Bijani Spring 2016.
1 Data Structures CSCI 132, Spring 2014 Lecture 2 Classes and Abstract Data Types Read Ch Read Style Guide (see course webpage)
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
INTRODUCTION TO CLASSES & OBJECTS CREATING CLASSES USING C#
 2007 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Introduction to Classes and Objects
Chapter 3 Introduction to Classes, Objects and Strings
Yanal Alahmad Java Workshop Yanal Alahmad
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 3 Introduction to Classes and Objects
Introduction to Classes and Objects
Dr Shahriar Bijani Winter 2017
IFS410: Advanced Analysis and Design
Advanced Programming Chapters 5 & 6: Control Structures
Week 3 Object-based Programming: Classes and Objects
Introduction to Classes and Objects
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall 2012 This set of slides is revised from lecture.
4 Introduction to Classes and Objects.
Classes, Objects, Methods and Strings
Object Oriented Programming in java
Properties.
Introduction to Classes and Objects
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Classes and Objects Systems Programming.
Presentation transcript:

Visual Programming Lecture 4

Operator Precedence

Methods, Classes, Objects, Method Calls, Attributes, Properties Discuss the definitions of Methods, Classes, Objects, Method Calls, Attributes, Properties (Get Accessor and Set Accessor) Create GradeBook class with the following code and test it: Using system; Public class GradeBook { public void DisplayMessage() Console.WriteLine(“Welcome to the Grade Book!”); }

Declaring a Method with Parameter Using system; Public class GradeBook { public void DisplayMessage(string courseName) Course.WriteLine(“Welcome to the grade book for \n{0}!”, courseName); }

Testing GradeBook GradeBook myGradeBook = new GradeBook(); Console.WriteLine(“Please enter the course name: “); String nameOfCourse = Console.ReadLine(); Console.WriteLine(); myGradeBook.DisplayMessage(nameOfCourse);

Instance Variables and Properties Variables declared inside a method are called “local variables” Variables declared inside class but outside method body are called “instance variables” Each object of a class has its own instance of “instance variable” Modify the GradeBook class as shown on next slide Also discuss UML class diagram

UML Diagram

Public class GradeBook { Private string courseName; Public string CourseName get { return courseName; } set { courseName = value; } Public void DisplayMessage() console.WriteLine(“Welcome to the grade book for \n{0}!”, CourseName); }

Testing GradeBook GradeBook myGradeBook = new GradeBook(); Console.WriteLine(“Initial course name is : ‘{0}’\n”, myGradeBook.CourseName); Console.WriteLine(“Please enter the course name: “); myGradeBook.CourseName = Console.ReadLine(); Console.WriteLine(); myGradeBook.DisplayMessage();

Auto Implemented Properties and Constructors Public class GradeBook { public string CourseName { get; set; } public GradeBook (string name) CourseName = name; } public void DisplayMessage() Console.WriteLine(“Welcome to the grade book for \n{0}!”, CourseName);

Testing GradeBook { GradeBook gradeBook1 = new GradeBook(“C# Programming”); GradeBook gradeBook2 = new GradeBook(“Data Structure”); Console.WriteLine(“gradeBook1 course name is : {0}”, gradeBook1.CourseName); Console.WriteLine(“gradeBook2 course name is : {0}”, gradeBook2.CourseName); }