Current Assignments Project 4 due next Saturday before midnight (Aug 2nd). Dinosaur classes. Comprehensive Final Exam on Thursday (July 31 st )

Slides:



Advertisements
Similar presentations
Current Assignments Homework 1 due in 4 days (June 16 th ) Variables, mathematical and logical operators, input/output, and the “ if ” operator. Project.
Advertisements

Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Shape.h Shape Point Circle Cylinder // SHAPE.H
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
Object Oriented Programming C++. ADT vs. Class ADT: a model of data AND its related functions C++ Class: a syntactical & programmatic element for describing.
Object Oriented Programming C++. ADT vs. Class ADT: a model of data AND its related functions C++ Class: a syntactical & programmatic element for describing.
Games and Simulations O-O Programming in Java The Walker School
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
CS 101: Arrays Abhiram Ranade. Computers manipulate many objects Given the position, masses, and velocities of all stars, where will they be after the.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 1.
Selection Statements in C++ If Statement in C++ Semantics: These statements have the same meaning as in the algorithmic language. 2- Two way selection:
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
CHAPTER 5 FUNCTIONS I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
Hank Childs, University of Oregon May 13th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / / __.
Monday, Mar 31, 2003Kate Gregory with material from Deitel and Deitel Week 12 Labs 4 and 5 are back File IO Looking ahead to the final.
Object-Oriented Programming. Procedural Programming All algorithms in a program are performed with functions and data can be viewed and changed directly.
1 Original Source : and Problem and Problem Solving.ppt.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 19 – Inheritance Part 2 Outline 19.8Direct Base Classes and Indirect Base Classes 19.9Using Constructors.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
1 12/4/1435 h Lecture 2 Programs and Programming Languages.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6: Transition to Java Programming with Alice and Java First Edition.
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
Programming in C++ Michal Brabec Petr Malý. Class / Struct Class / Struct consists of: data members function members constructors destructor copy constructor.
1 Lecture 17 Operator Overloading. 2 Introduction A number of predefined operators can be applied to the built- in standard types. These operators can.
The This Pointer Programming in C++ Fall 2008 Dr. David A. Gaitros
Arrays Dr. Jose Annunziato. Arrays Up to this point we have been working with individual primitive data types Arrays allow working with multiple instances.
1 2/21/05CS250 Introduction to Computer Science II Destructors, Get and Set, and Default Memberwise Assignment.
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan 3.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
 2003 Prentice Hall, Inc. All rights reserved Case Study: Three-Level Inheritance Hierarchy Three level point/circle/cylinder hierarchy –Point.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
1 Reference Variables Chapter 8 Page Reference Variables Safer version of C/C++ pointer. "Refers to" a variable. Like a pointer. Effectively.
Operator Overloading Chapter Objectives You will be able to Add overloaded operators, such as +,-, *, and / to your classes. Understand and use.
1 Introduction to Object Oriented Programming Chapter 10.
Lecture #6 Classes and Objects.
1 COMS 261 Computer Science I Title: Classes Date: November 4, 2005 Lecture Number: 27.
Lecture 7 Computer Programming -1-. Conditional Statements 1- if Statement. 2- if ….. else Statement. 3- switch.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 24: Pointers and Dynamic Allocation.
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 7 – Pointers.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 9 - Object-Oriented Programming: Inheritance Outline 9.1 Introduction 9.2 Base Classes and Derived.
Exception Handling How to handle the runtime errors.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Current Assignments Project 3 has been posted, due next Tuesday. Write a contact manager. Homework 6 will be posted this afternoon and will be due Friday.
A Sample Program #include using namespace std; int main(void) { cout
Software Engineering Algorithms, Compilers, & Lifecycle.
Pointers A variable that holds an address value is called a pointer variable, or simply a pointer.  What is the data type of pointer variables? It’s not.
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
Software Testing CS II: Data Structures & Abstraction
Pointers What is the data type of pointer variables?
Basic concepts of C++ Presented by Prof. Satyajit De
CMSC202 Computer Science II for Majors Lecture 08 – Overloaded Constructors Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
C++ Classes & Object Oriented Programming
Finally! Discussing a language!
group work #hifiTeam
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Chapter 2 Elementary Programming
Value returning Functions
Counting Loops.
الوحدة الرابعة البرمجة وصياغة حل المسائل البرمجة وأهميتها أهداف الدرس الأول مفهوم البرمجة. الفرق بين المبرمج ومستخدم البرنامج. الحاجة إلى البرامج.
Implementing Classes Chapter 3.
CS 1428 Final Exam Review.
CS150 Introduction to Computer Science 1
Function “Inputs and Outputs”
Summary of what we learned yesterday
Fundamental Programming
Input Based Programs.
Presentation transcript:

Current Assignments Project 4 due next Saturday before midnight (Aug 2nd). Dinosaur classes. Comprehensive Final Exam on Thursday (July 31 st )

Final Exam Everything that was on the first two exams plus basic classes and objects: –Class syntax –Private vs. Public –Constructors –Destructors –Class Methods –Instantiation of classes –Using objects

Sample Problem (find syntax errors) In Test.h class Test { public float Test(); float Test( float i ); method1( float x ); method2( float y); ~Test(); ~Test( int x ) private float var; } In Test.cpp Test:Test() { var = 0.0; } float Test:Test(float i) { var = i; } float Test:method1( float x, float y ) { return x*y*var; } float Test:method2( float y ) { return (y+var)*y; } Test:~Test() { } Test:~Test( int x ) { }

Sample Problem (find the logic error) In Test.h class Test { public: float method1( float x ); float method2( float y); ~Test(); private: Test(); Test( float i ); float var; } In Test.cpp #include “Test.h” Test::Test() { var = 0.0; } Test::Test(float i) { var = i; } float Test::method1( float x ) { return x*var; } float Test::method2( float y ) { return (y+var)*y; } Test::~Test() { }

Sample Problem (give the output) In Test.h class Test { public: Test( float i ); float method1( float x ); ~Test(); private: float var; }; In Test.cpp #include “Test.h” Test::Test(float i) { var = i; } float Test::method1( float x ) { return x*var; } Test::~Test() { } In driver.cpp … #include “Test.h” int main() { Test a_test( 4.0 ); cout << “Result: “ << a_test.method1( 2.0 ) << endl; …

Sample Problem You will be required to write programs like those on the first two exams (including one recursive function). Example class program: Write a Circle class to represent circles. Your circle class must store the radius of the circle in a private data member called radius of type float. Your circle class must define two public methods called diameter (2r) and area (3.14r 2 ) that take no arguments and return the diameter and area of the circle defined by radius in your circle object. Give your circle objects a value for radius when they are created (i.e. with a constructor). Write a driver program to create two circles of radius 1.0 and 2.0. and which prints the area and diameter of your circles.

Sample Problem (give the output) In Circle.h class Circle { public: Circle( int r ); float diameter(); float area(); private: float radius; }; In Circle.cpp #include “Circle.h” Circle::Circle(float r) { radius = r; } float Circle::diameter() { return 2*radius; } float Circle::area() { return 3.14*radius*radius; } In driver.cpp … #include “Test.h” int main() { Circle circle1( 2.0 ), circle2(1.0); cout << “Area: “ << circle1.area() <<“ “<< circle1.diameter() << endl; cout << “Area: “ << circle2.area() <<“ “<< circle2.diameter() << endl; …

The End - Programming Computers and the software they run are becoming ubiquitous. In this course you learned how computers are used to solve problems. You learned how to use functions, iteration, recursion, and objects to solve various problems. You wrote software to solve mathematical problems, play games, store information (a database), and simulate extinct animals.

The End – C++ You understand how to write and compile fairly complex programs in C++. You have been exposed to all the major elements of C++, variables, control structures, functions, classes, input and output. Make sure you put C++ on your resume!