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

Size: px
Start display at page:

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

Transcription

1 public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance; public double deposit(double amount) { public double withdraw(double amount) {

2

3

4 getid()is unique and set when account is created getname()is set when account is created the values of getid() and getname() never change public class Account { private int id;

5

6

7 Chapter 15 Chapter 11

8

9

10 /** * Deposit money into the account amount The amount to be deposited * true IF amount >= 0 * THEN getbalance() + amount * ELSE getbalance() IllegalValueException if amount is negative */ public void deposit(double amount) throws IllegalValueException { if (amount < 0) throw new IllegalValueException("Error: Neg. amount"); balance = balance + amount; }

11 IllegalValueException IllegalValueException

12 IllegalValueException

13

14

15

16 /** * A simple bank account for which the balance can never be * less than zero * getbalance() >= 0 getid() is unique and set when account is created getname() is set when account is created the values of getid() and getname() never change */ public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;

17 /** * Initializes an account accountname Customer name for account initialbalance Initial balance deposited in account * true getname() = accountname getid() = a new number not returned by other accounts (initialbalance>=0 AND getbalance() = initialbalance) * OR getbalance() = 0 * */ public Account(String accountname, double initialbalance) { id = nextaccountid++; name = accountname; if (initialbalance >= 0) balance = initialbalance; else balance = 0; } /** * Accessor method to return the account id true the account id */ public int getid() { return id; } /** * Accessor method to return the customer name true he customer name */ public String getname() { return name; } /** * Deposit money into the account amount The amount to be deposited * amount >= 0 getbalance() + amount The current balance of the account */ public double deposit(double amount) { assert amount >= 0; balance = balance + amount; return balance; } /** * Withdraw money from the account amount The amount to be withdrawn * amount >= 0 IF (@pre.getbalance()-amount >= 0 ) * THEN getbalance() - amount * ELSE getbalance() The current balance of the account */ public double withdraw(double amount) { assert amount >= 0; if (balance - amount >= 0) balance = balance - amount; return balance; }

18 /** * Returns the string representation of an account * true the account represented as a string */ public String tostring() { return "[ id = " + id + ", name = " + name + ", balance = " + balance + "]"; } }

Chapter 15 Chapter 11

Chapter 15 Chapter 11 Chapter 15 Chapter 11 /** * Deposit money into the account * @param amount The amount to be deposited * * @pre true * @post IF amount >= 0 * THEN getbalance() = @pre.getbalance() + amount * ELSE getbalance()

More information

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017 This week the main activity was a quiz activity, with a structure similar to our Friday lecture activities. The retrospective for the quiz is in Quiz-07- retrospective.pdf This retrospective explores the

More information

Administrivia. CPSC Winter 2008 Term 1. Department of Computer Science Undergraduate Events

Administrivia. CPSC Winter 2008 Term 1. Department of Computer Science Undergraduate Events Department of Computer Science Undergraduate Events Events this week Drop-In Resume Editing Date: Mon. Jan 11 Time: 11 am 2 pm Location: Rm 255, ICICS/CS Industry Panel Speakers: Managers from IBM, Microsoft,

More information

Practice problem on defining and using Class types. Part 4.

Practice problem on defining and using Class types. Part 4. CS180 Programming Fundamentals Practice problem on defining and using Class types. Part 4. Implementing object associations: Applications typically consist of collections of objects of different related

More information

Encapsulation. Mason Vail Boise State University Computer Science

Encapsulation. Mason Vail Boise State University Computer Science Encapsulation Mason Vail Boise State University Computer Science Pillars of Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction (sometimes) Object Identity Data (variables) make

More information

Handout 8 Classes and Objects Continued: Static Variables and Constants.

Handout 8 Classes and Objects Continued: Static Variables and Constants. Handout 8 CS603 Object-Oriented Programming Fall 16 Page 1 of 8 Handout 8 Classes and Objects Continued: Static Variables and Constants. 1. Static variable Declared with keyword static One per class (instead

More information

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

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2) WE1 W o r k e d E x a m p l e 2 2.1 Programming a Bank Database In this Worked Example, we will develop a complete database program. We will reimplement the ATM simulation of Chapter 12, storing the customer

More information

Lab4 Task2- Solution LAB ASSIGNMENT:

Lab4 Task2- Solution LAB ASSIGNMENT: Lab4 Task2- Solution LAB ASSIGNMENT: Write down a StudentAccount class having the following attributes and operations (methods) and save it as studacct.h file: Attributes: long studentid String studentname

More information

Review. these are the instance variables. these are parameters to the methods

Review. these are the instance variables. these are parameters to the methods Review Design a class to simulate a bank account Implement the class Write a demo program that creates bank accounts Write junit tests for the bank account class Review What data items are associated with

More information

Object oriented programming

Object oriented programming Exercises 7 Version 1.0, 11 April, 2017 Table of Contents 1. Inheritance.................................................................. 1 1.1. Tennis Player...........................................................

More information

Outline CSE 142. Specification vs Implementation - Review. CSE142 Wi03 F-1. Instance Variables

Outline CSE 142. Specification vs Implementation - Review. CSE142 Wi03 F-1. Instance Variables Outline CSE 142 Class Implementation in Java Implementing classes in Java Instance variables properties Value-returning methods for queries Void methods for commands Return statement Assignment statement

More information

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED EXERCISE 11.1 1. static public final int DEFAULT_NUM_SCORES = 3; 2. Java allocates a separate set of memory cells in each instance

More information

$ % $ % BankAccount. public class BankAccount {... private??? balance; } "commands, transformers, mutators! "abstract state! "queries, accessors!

$ % $ % BankAccount. public class BankAccount {... private??? balance; } commands, transformers, mutators! abstract state! queries, accessors! "! public class { private??? balance; "! # "! "commands, transformers, mutators! "abstract state! "queries, accessors! "constructors! & "! public class { private double balance; "! void "this! x.command1();

More information

Storing Data in Objects

Storing Data in Objects Storing Data in Objects Rob Miles Department of Computer Science 28d 08120 Programming 2 Objects and Items I have said for some time that you use objects to represent things in your problem Objects equate

More information

Implementing Classes

Implementing Classes Implementing Classes Advanced Programming ICOM 4015 Lecture 3 Reading: Java Concepts Chapter 3 Fall 2006 Slides adapted from Java Concepts companion slides 1 Chapter Goals To become familiar with the process

More information

STUDENT LESSON A5 Designing and Using Classes

STUDENT LESSON A5 Designing and Using Classes STUDENT LESSON A5 Designing and Using Classes 1 STUDENT LESSON A5 Designing and Using Classes INTRODUCTION: This lesson discusses how to design your own classes. This can be the most challenging part of

More information

Implementing Classes (P1 2006/2007)

Implementing Classes (P1 2006/2007) Implementing Classes (P1 2006/2007) Fernando Brito e Abreu (fba@di.fct.unl.pt) Universidade Nova de Lisboa (http://www.unl.pt) QUASAR Research Group (http://ctp.di.fct.unl.pt/quasar) Chapter Goals To become

More information

BankAccount account1 = new BankAccount(...);,this

BankAccount account1 = new BankAccount(...);,this 1 6 ',, : (.new ) BankAccount account1 = new BankAccount(...); פ, פ,this,, ) \ פ\( פ פ פ 2 ) ( " פ : :? public class BankAccount {... private double balance;... 3 :),, ( 3 )queries, accessors( ), ( :)observers(

More information

Agenda: Notes on Chapter 3. Create a class with constructors and methods.

Agenda: Notes on Chapter 3. Create a class with constructors and methods. Bell Work 9/19/16: How would you call the default constructor for a class called BankAccount? Agenda: Notes on Chapter 3. Create a class with constructors and methods. Objectives: To become familiar with

More information

Intro to Computer Science 2. Inheritance

Intro to Computer Science 2. Inheritance Intro to Computer Science 2 Inheritance Admin Questions? Quizzes Midterm Exam Announcement Inheritance Inheritance Specializing a class Inheritance Just as In science we have inheritance and specialization

More information

Data types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 12/2/2015

Data types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 12/2/2015 CISC 1600/1610 Computer Science I Classes Professor Daniel Leeds dleeds@fordham.edu JMH 328A Data types Single pieces of information one integer int one symbol char one truth value bool Multiple pieces

More information

Practical Session 2 Correction Don't forget to put the InputValue.java file in each project

Practical Session 2 Correction Don't forget to put the InputValue.java file in each project Practical Session 2 Correction Don't forget to put the InputValue.java file in each project Exercise 1 : Bank Account 1) BankAccount class A bank account is a financial account with a banking institution

More information

Chapter Goals. Chapter 9 Inheritance. Inheritance Hierarchies. Inheritance Hierarchies. Set of classes can form an inheritance hierarchy

Chapter Goals. Chapter 9 Inheritance. Inheritance Hierarchies. Inheritance Hierarchies. Set of classes can form an inheritance hierarchy Chapter Goals To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package access control To

More information

COMP-202 Unit 8: Defining Your Own Classes. CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation

COMP-202 Unit 8: Defining Your Own Classes. CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation COMP-202 Unit 8: Defining Your Own Classes CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation Defining Our Own Classes (1) So far, we have been creating

More information

SWC test question #01. Using objects part I

SWC test question #01. Using objects part I SWC test question #01 Using objects part I Using objects part I Give a presentation of the concept objects, and how you use objects You could describe Types Variables Variable definitions The assignment

More information

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

Eduardo M. Breijo Baullosa May 2, Assignment 17. Report Eduardo M. Breijo Baullosa May 2, 2012 Cesar I. Cruz ICOM4015 Assignment 17 Report The Automated teller machine is a computer that allows the interaction between bank account information and its respective

More information

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

C C C C++ 2 ( ) C C++ 4 C C # 7 11 13 C 4 8 11 20 C 9 11 27 C++ 1 10 12 4 C++ 2 11 12 11 C++ 3 12 12 18 C++ 4 C++ 5 13 1 8 ( ) 14 1 15 C++ 15 1 22 2 (D) ( ) C++ 3 6 Hello C++ 4 5 1. make Makefile.c (arithmetic.c) main main arithmetic

More information

ICOM 4015: Advanced Programming

ICOM 4015: Advanced Programming ICOM 4015: Advanced Programming Lecture 3 Reading: Chapter Three: Implementing Classes Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter Three - Implementing Classes Chapter Goals To become

More information

Practice Midterm Examination

Practice Midterm Examination Steve Cooper Handout #28 CS106A May 1, 2013 Practice Midterm Examination Midterm Time: Tuesday, May 7, 7:00P.M. 9:00P.M. Portions of this handout by Eric Roberts and Patrick Young This handout is intended

More information

Assertions, pre/postconditions

Assertions, pre/postconditions Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What

More information

ATM Use Cases. ID: CIS Title: Check Balance Description: Customer aims to know the balance in his/her account

ATM Use Cases. ID: CIS Title: Check Balance Description: Customer aims to know the balance in his/her account ID: CIS375-01 Title: Login Description: Customer logs into the system by inserting the card and entering pin code. Preconditions: Customer has a bank account and an ATM Card. Postconditions: Customer logged

More information

CHAPTER 10 INHERITANCE

CHAPTER 10 INHERITANCE CHAPTER 10 INHERITANCE Inheritance Inheritance: extend classes by adding or redefining methods, and adding instance fields Example: Savings account = bank account with interest class SavingsAccount extends

More information

CS 106X, Lecture 14 Classes and Pointers

CS 106X, Lecture 14 Classes and Pointers CS 106X, Lecture 14 Classes and Pointers reading: Programming Abstractions in C++, Chapter 6, 11 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

Inheritance Advanced Programming ICOM 4015 Lecture 11 Reading: Java Concepts Chapter 13

Inheritance Advanced Programming ICOM 4015 Lecture 11 Reading: Java Concepts Chapter 13 Inheritance Advanced Programming ICOM 4015 Lecture 11 Reading: Java Concepts Chapter 13 Fall 2006 Adapted from Java Concepts Companion Slides 1 Chapter Goals To learn about inheritance To understand how

More information

Inheritance (P1 2006/2007)

Inheritance (P1 2006/2007) Inheritance (P1 2006/2007) Fernando Brito e Abreu (fba@di.fct.unl.pt) Universidade Nova de Lisboa (http://www.unl.pt) QUASAR Research Group (http://ctp.di.fct.unl.pt/quasar) Chapter Goals To learn about

More information

Quarter 1 Practice Exam

Quarter 1 Practice Exam University of Chicago Laboratory Schools Advanced Placement Computer Science Quarter 1 Practice Exam Baker Franke 2005 APCS - 12/10/08 :: 1 of 8 1.) (10 percent) Write a segment of code that will produce

More information

Sample Solution Assignment 5. Question R3.1

Sample Solution Assignment 5. Question R3.1 Sample Solution Assignment 5 Question R3.1 The interface of a class is the part that the user interacts with, not necessarily knowing how it works. An implementation of is the creation of this interface.

More information

Arrays and Array Lists

Arrays and Array Lists Arrays and Array Lists Advanced Programming ICOM 4015 Lecture 7 Reading: Java Concepts Chapter 8 Fall 2006 Slides adapted from Java Concepts companion slides 1 Lecture Goals To become familiar with using

More information

Chapter 8. Arrays and Array Lists. Chapter Goals. Chapter Goals. Arrays. Arrays. Arrays

Chapter 8. Arrays and Array Lists. Chapter Goals. Chapter Goals. Arrays. Arrays. Arrays Chapter 8 Arrays and Array Lists Chapter Goals To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing and the generalized for loop To study common array algorithms

More information

Data types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 4/19/2015

Data types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 4/19/2015 CISC 1600/1610 Computer Science I Classes Professor Daniel Leeds dleeds@fordham.edu JMH 328A Data types Single pieces of information one integer int one symbol char one truth value bool Multiple pieces

More information

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

CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism Review from Lecture 22 Added parent pointers to the TreeNode to implement increment and decrement operations on tree

More information

Using the Xcode Debugger

Using the Xcode Debugger g Using the Xcode Debugger J Objectives In this appendix you ll: Set breakpoints and run a program in the debugger. Use the Continue program execution command to continue execution. Use the Auto window

More information

Chapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.

Chapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 10 Inheritance Chapter Goals To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package

More information

Date: AIM. Write a Java program to demo simple inheritance PROCEDURE

Date: AIM. Write a Java program to demo simple inheritance PROCEDURE Ex.No 7 Date: AIM INHERITANCE Write a Java program to demo simple inheritance PROCEDURE 1. Create a class stud which includes student name,major,year, rollno. 2. Create a class mark which extends the stud

More information

2/9/2012. Chapter Three: Implementing Classes. Chapter Goals

2/9/2012. Chapter Three: Implementing Classes. Chapter Goals Chapter Three: Implementing Classes Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To

More information

9/2/2011. Chapter Goals

9/2/2011. Chapter Goals Chapter Goals To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To understand how to access instance fields

More information

Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100

Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100 Department of Computer Science Undergraduate Events Events this week Drop-In Resume Edition Date: Mon. Jan 11 Time: 11 am 2 pm Location: Rm 255, ICICS/CS Industry Panel Speakers: Managers from IBM, Microsoft,

More information

BloomBank Financial Software Design

BloomBank Financial Software Design BloomBank Financial Software Design CIS 3023 Project 6 Due date: Report on project classes and methods - July 27 th, 200 (Tue) Complete implementation - August 3 rd, 200 (Tue) Problem Statement: You work

More information

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

EXAMINATIONS 2012 END-OF-YEAR SWEN222. Software Design. Question Topic Marks 1. Design Quality Design Patterns Design by Contract 12 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:..................... EXAMINATIONS 2012 END-OF-YEAR SWEN222 Software Design Time

More information

CSCI-1200 Data Structures Fall 2017 Lecture 25 C++ Inheritance and Polymorphism

CSCI-1200 Data Structures Fall 2017 Lecture 25 C++ Inheritance and Polymorphism SI-1200 ata Structures Fall 2017 Lecture 25 ++ Inheritance and Polymorphism Review from Lecture 24 (& Lab 12!) Finish hash table implementation: Iterators, find, insert, and erase asic data structures

More information

CSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes

CSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes CSEN401 Computer Programming Lab Topics: Introduction and Motivation Recap: Objects and Classes Prof. Dr. Slim Abdennadher 16.2.2014 c S. Abdennadher 1 Course Structure Lectures Presentation of topics

More information

Building Your Own Classes

Building Your Own Classes COMP-202 Building Your Own Classes Lecture Outline Anatomy of a Class Methods Method Kinds Method Signature Method Invocation Method Body Parameter Passing The Bank Application Example Instance Data public

More information

Location: Planet Laser Interview Skills Workshop

Location: Planet Laser Interview Skills Workshop Department of Computer Science Undergraduate Events Events this week Drop in Resume/Cover Letter Editing Date: Tues., Jan 19 CSSS Laser Tag Time: 12:30 2 pm Date: Sun., Jan 24 Location: Rm 255, ICICS/CS

More information

Class 09 Slides: Polymorphism Preconditions. Table of Contents. Postconditions

Class 09 Slides: Polymorphism Preconditions. Table of Contents. Postconditions Class 09 Slides: Polymorphism Preconditions Students are familiar with inheritance and arrays. Students have worked with a poorly written program in A08 that could benefit from polymorphism. Students have

More information

Chapter Seven: Arrays and Array Lists. Chapter Goals

Chapter Seven: Arrays and Array Lists. Chapter Goals Chapter Seven: Arrays and Array Lists Chapter Goals To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing and the generalized for loop To study common array algorithms

More information

Handout 9 OO Inheritance.

Handout 9 OO Inheritance. Handout 9 CS603 Object-Oriented Programming Fall 2016 Page 1 of 11 Handout 9 OO Inheritance. All classes in Java form a hierarchy. The top of the hierarchy is class Object Example: classicalarchives.com

More information

Lecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos.

Lecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos. Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 07: Object Encapsulation & References AITI Nigeria Summer 2012 University of Lagos. Data Field Encapsulation Sometimes we want

More information

CSIS 10A Practice Final Exam Name:

CSIS 10A Practice Final Exam Name: CSIS 10A Practice Final Exam Name: Multiple Choice: Each question is worth 2 points. Circle the letter of the best answer for the following questions. 1. For the following declarations: int area; String

More information

Outline for Today CSE 142. CSE142 Wi03 G-1. withdraw Method for BankAccount. Class Invariants

Outline for Today CSE 142. CSE142 Wi03 G-1. withdraw Method for BankAccount. Class Invariants CSE 142 Outline for Today Conditional statements if Boolean expressions Comparisons (=,!=, ==) Boolean operators (and, or, not - &&,,!) Class invariants Conditional Statements & Boolean Expressions

More information

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/]

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] COMPSCI 230 Threading Week8 Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] Synchronization Lock DeadLock Why do we need Synchronization in Java? If your code is executing

More information

Chapter Goals. T To understand the concept of regression testing. Chapter 6 Arrays and Array Lists. Arrays Array: Sequence of values of the same type

Chapter Goals. T To understand the concept of regression testing. Chapter 6 Arrays and Array Lists. Arrays Array: Sequence of values of the same type Chapter Goals To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing and the generalized for loop To study common array algorithms To learn how to use two-dimensional

More information

Programming Abstractions

Programming Abstractions Programming Abstractions C S 1 0 6 B Cynthia Lee Topics du Jour: Make your own classes! Needed for Boggle assignment! We are starting to see a little bit in MarbleBoard assignment as well 2 Classes in

More information

CSE 142, Spring 2010 Final Exam Wednesday, June 9, Name: Student ID #: Rules:

CSE 142, Spring 2010 Final Exam Wednesday, June 9, Name: Student ID #: Rules: CSE 142, Spring 2010 Final Exam Wednesday, June 9, 2010 Name: Section: Student ID #: TA: Rules: You have 110 minutes to complete this exam. You may receive a deduction if you keep working after the instructor

More information

6.096 Introduction to C++

6.096 Introduction to C++ MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. MASSACHUSETTS INSTITUTE

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking

More information

COSC This week. Will Learn

COSC This week. Will Learn This week COSC1030.03 Read chapters 9, 11 S tart thinking about assignment 2 Week 4. J anuary 26, 2004 Will Learn how to inherit and override superclass methods how to invoke superclass constructors about

More information

Software Engineering: Design & Construction

Software Engineering: Design & Construction Software Engineering: Design & Construction Department of Computer Science Software Technology Group Practice Exam May 22, 2015 First Name Last Name Matriculation Number Course of Study Department Signature

More information

Exercises 1. class member { int membernum = 25; float memberpay; public void Input(cin >> membernum >> memberpay); void Output; }

Exercises 1. class member { int membernum = 25; float memberpay; public void Input(cin >> membernum >> memberpay); void Output; } Exercises 1 Part 1: Explain the output of the following code without running it: struct data { float z; char type; }; int main() { data D1 = {20, 'P'}; cout

More information

CMSC 202. Exceptions

CMSC 202. Exceptions CMSC 202 Exceptions Error Handling In the ideal world, all errors would occur when your code is compiled. That won t happen. Errors which occur when your code is running must be handled by some mechanism

More information

CS1020 Data Structures and Algorithms I Lecture Note #8. Exceptions Handling exceptional events

CS1020 Data Structures and Algorithms I Lecture Note #8. Exceptions Handling exceptional events CS1020 Data Structures and Algorithms I Lecture Note #8 Exceptions Handling exceptional events Objectives Understand how to use the mechanism of exceptions to handle errors or exceptional events that occur

More information

Assertions. Assertions - Example

Assertions. Assertions - Example References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 11/13/2003 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,

More information

Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs.

Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs. Lab 8 Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs. Preparation: Exercise using the Account class We will be modifying the code of the Transactions

More information

Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs.

Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs. Lab 8 Name: Checked: Objectives: Practice creating classes and methods, and using them in your programs. Preparation A: Exercise using the Die class Create a subfolder Dice for your files in this exercise.

More information

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

Implementation. (Mapping to Java) Jörg Kienzle & Alfred Strohmeier. COMP-533 Implementation Implementation (Mapping to Java) Jörg Kienzle & Alfred Strohmeier COMP-533 Implementation Datatype Enumeration Class Attribute Association Inheritance Method Visibility Collections Overview 2 Data Type

More information

Introduction to Inheritance

Introduction to Inheritance Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits

More information

Instance Method Development Demo

Instance Method Development Demo Instance Method Development Demo Write a class Person with a constructor that accepts a name and an age as its argument. These values should be stored in the private attributes name and age. Then, write

More information

Developed By Strawberry

Developed By Strawberry Experiment No. 3 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To study below concepts of classes and objects 1. Array of Objects 2. Objects as a function argument 3. Static Members P1: Define a

More information

CSCI-1200 Data Structures Spring 2016 Lecture 23 C++ Exceptions, Inheritance, and Polymorphism

CSCI-1200 Data Structures Spring 2016 Lecture 23 C++ Exceptions, Inheritance, and Polymorphism CSCI-1200 Data Structures Spring 2016 Lecture 23 C++ Exceptions, Inheritance, and Polymorphism Announcements There was a bug in priority queue.h in provided files.zip, but not in the linked version of

More information

IT 313 Advanced Application Development

IT 313 Advanced Application Development Page 1 of 7 IT 313 Advanced Application Development Practice Midterm Exam Part A. Multiple Choice Questions. Answer all questions. Optional: supply a reason or show work for partial credit in case you

More information

Classes and Methods: Classes

Classes and Methods: Classes Class declaration Syntax: [] Classes and Methods: Classes [] class [] [] [] When

More information

CSC 175 Intermediate Programming

CSC 175 Intermediate Programming CSC 175 Intermediate Programming Lecture 6 Inheritance Inheritance and Derived Classes Inheritance is the process by which a new class is created from another class. The new class is called the derived

More information

Integrating verification in programming languages

Integrating verification in programming languages Integrating verification in programming languages Thomas Jensen, INRIA Seminar INRIA Rennes, 04/11/2015 Collège de France Chaire Algorithmes, machines et langages x / y Types For division to make sense,

More information

Chapter 5: Arrays. Chapter 5. Arrays. Java Programming FROM THE BEGINNING. Copyright 2000 W. W. Norton & Company. All rights reserved.

Chapter 5: Arrays. Chapter 5. Arrays. Java Programming FROM THE BEGINNING. Copyright 2000 W. W. Norton & Company. All rights reserved. Chapter 5 Arrays 1 5.1 Creating and Using Arrays A collection of data items stored under a single name is known as a data structure. An object is one kind of data structure, because it can store multiple

More information

Chapter Goals. Chapter 5 - Iteration. Calculating the Growth of an Investment

Chapter Goals. Chapter 5 - Iteration. Calculating the Growth of an Investment Chapter Goals To be able to program loops with the while and for statements To avoid infinite loops and off-by-one errors To be able to use common loop algorithms To understand nested loops To implement

More information

Mutating Object State and Implementing Equality

Mutating Object State and Implementing Equality Mutating Object State and Implementing Equality 6.1 Mutating Object State Goals Today we touch the void... (sounds creepy right... see the movie, or read the book, to understand how scary the void can

More information

1/9/2015. Intro to CS: Java Review Assignment Due Dates Chapter 7 7.1: while Loops 7.2: for Loops Ch7 Work Time. Chapter 7 Iteration WHILE LOOPS

1/9/2015. Intro to CS: Java Review Assignment Due Dates Chapter 7 7.1: while Loops 7.2: for Loops Ch7 Work Time. Chapter 7 Iteration WHILE LOOPS Chapter 7 Iteration The Plan For Today Intro to CS: Java Review Assignment Due Dates Chapter 7 7.1: while Loops 7.2: for Loops Ch7 Work Time WHILE LOOPS Executes a block of code repeatedly A condition

More information

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName;

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName; WEEK 13 EXAMPLES MONDAY SECTION 2 Author class public class Author { private static int ID=0; private String AuthorName; private String DOB; public Author() { AuthorName = ""; DOB = ""; public Author(String

More information

Five EASY Steps to Switch to

Five EASY Steps to Switch to Five EASY Steps to Switch to Peoples Bank & Trust Company It s easy to switch your accounts to Peoples Bank & Trust Company because we ll help. We ll provide the forms and a check list of simple things

More information

FDSc in ICT. Building a Program in C#

FDSc in ICT. Building a Program in C# 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

More information

Testooj user s manual October 25, 2007

Testooj user s manual October 25, 2007 Testooj user s manual October 25, 2007 A testing tool developed by: Alarcos Research Group Department of Information Systems and Technologies University of Castilla-La Mancha Project leader: Macario Polo

More information

class declaration Designing Classes part 2 Getting to know classes so far Review Next: 3/18/13 Driver classes:

class declaration Designing Classes part 2 Getting to know classes so far Review Next: 3/18/13 Driver classes: Designing Classes part 2 CSC 1051 Data Structures and Algorithms I Getting to know classes so far Predefined classes from the Java API. Defining classes of our own: Driver classes: Account Transactions

More information

Catching Defects: Design or Implementation Phase? Design-by-Contract (Dbc) Test-Driven Development (TDD) Motivation of this Course

Catching Defects: Design or Implementation Phase? Design-by-Contract (Dbc) Test-Driven Development (TDD) Motivation of this Course Design-by-Contract (Dbc) Test-Driven Development (TDD) Readings: OOSC2 Chapter 11 Catching Defects: Design or Implementation Phase? To minimize development costs, minimize software defects. The cost of

More information

CSE 143 Lecture 3. More ArrayList; object-oriented programming. reading: 10.1;

CSE 143 Lecture 3. More ArrayList; object-oriented programming. reading: 10.1; CSE 143 Lecture 3 More ArrayList; object-oriented programming reading: 10.1; 8.1-8.7 slides created by Marty Stepp http://www.cs.washington.edu/143/ Out-of-bounds Legal indexes are between 0 and the list's

More information

Inheritance & Abstract Classes Fall 2018 Margaret Reid-Miller

Inheritance & Abstract Classes Fall 2018 Margaret Reid-Miller Inheritance & Abstract Classes 15-121 Margaret Reid-Miller Today Today: Finish circular queues Exercise: Reverse queue values Inheritance Abstract Classes Clone 15-121 (Reid-Miller) 2 Object Oriented Programming

More information

CSE 331. Programming by contract: pre/post conditions; Javadoc

CSE 331. Programming by contract: pre/post conditions; Javadoc CSE 331 Programming by contract: pre/post conditions; Javadoc slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/ 1

More information

More Shared Memory Programming

More Shared Memory Programming More Shared Memory Programming Shared data structures We want to make data structures that can be shared by threads. For example, our program to copy a file from one disk to another used a shared FIFO

More information

CSE 413 Winter 2001 Midterm Exam

CSE 413 Winter 2001 Midterm Exam Name ID # Score 1 2 3 4 5 6 7 8 There are 8 questions worth a total of 75 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to

More information

Final Exam Time: Friday, August 12th, 12:15pm - 3:15pm Final Exam Location: Split by last name

Final Exam Time: Friday, August 12th, 12:15pm - 3:15pm Final Exam Location: Split by last name Alisha Adam and Rohit Talreja CS 106A Summer 2016 Practice Final #2 Final Exam Time: Friday, August 12th, 12:15pm - 3:15pm Final Exam Location: Split by last name Last name starting with A P NVIDIA Auditorium

More information

What will this print?

What will this print? class UselessObject{ What will this print? int evennumber; int oddnumber; public int getsum(){ int evennumber = 5; return evennumber + oddnumber; public static void main(string[] args){ UselessObject a

More information

What This Course Is About Design-by-Contract (DbC)

What This Course Is About Design-by-Contract (DbC) What This Course Is About Design-by-Contract (DbC) Readings: OOSC2 Chapter 11 EECS3311 A: Software Design Fall 2018 CHEN-WEI WANG Focus is design Architecture: (many) inter-related modules Specification:

More information