Designing Classes Lab. The object that you brought to class Put it in the basket we will exchange them now.

Slides:



Advertisements
Similar presentations
Planning 10 Learning Guide 15 Planning 10 Learning Guide 15 Money Management Chequing Accounts Click for next Watch this corner for prompts on when you.
Advertisements

IMPLEMENTING CLASSES Chapter 3. Black Box  Something that magically does its thing!  You know what it does but not how.  You really don’t care how.
1 Objects, Classes, and Packages “Static” Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Requirements and Design
Chapter 3 Implementing Classes. Instance Variables Instance variables store the data of an object; the fields of an object. Instance of a class: an object.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter Three - Implementing Classes.
The child gets it all..  Factor out common behavior  parent class implements behavior needed by children  guarantee that all subclasses have the characteristics.
TA: Nouf Al-Harbi NoufNaief.net :::
CHAPTER 2 OBJECTS AND CLASSES Goals: To understand the concepts of classes and objects To realize the difference between objects and object references.
CS100J 11 September 2003 Course Management System for CS100J is now populated with students who were pre-registered. Look at course web page to see how.
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
More Game GUI and methods. This is where we left off.
IEG 3080 Tutorial 6 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline UML Basic Class Diagram Sequence Diagram Examples Assignment 2 General Concept.
Inheritance and Subclasses in Java CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
CS 241 – Computer Programming II Lab Kalpa Gunaratna –
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
Writing Classes (Chapter 4)
Glenn David Blank Computer Science & Engineering Department Lehigh University, Bethlehem, PA, USA With support from the National Science Foundation (Grants.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
Introduction to Object-Oriented Programming
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Creating Simple Classes. Outline of Class Account Class Account Account # Balance Holder name phone# Overdrawn (true/false) Data Members Open Credit Debit.
Constructing Objects Lab. Log into Wiley Plus Read the problem Write a BankAccountTester class whose main method constructs a bank account, deposits.
Bank Account Reconciliation. Reconciling The process of matching your checkbook register with the bank statement is known as reconciliation. The back.
 For thousands of years, people have used some sort of currency or type of money to pay for things they want. Different countries and cultures have used.
Object-Oriented Programming in C++
Lecture 21 CS110 Lecture 2 January 29, 2004 Announcements –hw1 part 1 – due right now –hw1 part 2 – due Tuesday night Questions Agenda –turnin –Object.
UML Review – class diagrams SE 2030 Dr. Rob Hasker 1 Based on slides written by Dr. Mark L. Hornick Used with permission.
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
ACO 101 Instantiating Graphic Objects. Review: 4 Phases to the Development Lifecycle Inception (Analysis & Design) – Business Requirements Business Analyst.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Classes: Member Functions and Implementation November 22, 2002 CSE103 - Penn State University Prepared by Doug Hogan.
 28object-oriented_programming%29 28object-oriented_programming%29.
Session 04: C# OOP 2 OOP in C#: Object-Oriented Design.
Session 02 and 03: C# OOP 1 OOP in C#: Classes and Objects in C#. Object-Oriented Design. UML Class Diagram. Object Interaction. FEN AK IT:
Lecture 121 CS110 Lecture 12 Tuesday, March 9, 2004 Announcements –hw5 due Thursday –Spring break next week Agenda –questions –ArrayList –TreeMap.
GOALS BUSINESS MATH© Thomson/South-WesternLesson 3.4Slide 1 3.4Check Register Reconciliation Reconcile a bank statement Reconcile and correct a check register.
ACM/JETT Workshop - August 4-5, : Defining Classes in Java.
Copyright by Scott GrissomCh 2 Class Definition Slide 1 Class Structure public class BankAccount{ fields constructor(s) methods } Sample Code Ticket Machine.
Class Design I Class Contracts Readings: 2 nd Ed: Section 9.5, Advanced Topic nd Ed: Section 8.5, Advanced Topic 8.2 Some ideas come from: “Practical.
Problem 1 Bank.  Manage customers’ bank account using the following operations: Create a new account given a customer’s name and initial account. Deposit.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
CHECKBOOK PREPARATION for Enterprise City. Your checkbook has three parts: Register pages Checks Deposit Slips.
1 10/15/04CS150 Introduction to Computer Science 1 Reading from and Writing to Files Part 2.
1.2 Adding Integers Adding 3 or more terms. Strategy You can add everything going from left to right Or you can use Commutative and Associative Properties.
Balancing Accounts Mr. BarryA-Level Accounting Year 12.
Monday, Jan 27, 2003Kate Gregory with material from Deitel and Deitel Week 4 Questions from Last Week Hand in Lab 2 Classes.
CS110 Introduction to Programming Lecture 1 January 27, 2004 Ethan Bolker Philosophy Bank: user interface, Java, object model Programming environment Homework.
Chapter 3 Implementing Classes
Do Now Why do people have checking accounts?. Unit 4: Lesson 13: Checking Accounts Day 1 Objective: identify vocabulary terms related to checking accounts.
Banking Review. Bank Business that stores money for individuals and businesses.
Return to Home! Go To Next Slide! Return to Home! Go To Next Slide!
End of the internship PARTI Meeting September 11, 2008 A. Shemyakin, M. Bruce.
Lecture 3 John Woodward.
Java OOP Overview Classes and Objects, Members and Class Definition, Access Modifier, Encapsulation Java OOP Overview SoftUni Team Technical Trainers.
LESSON 4-2 Posting from a General Journal to a General Ledger
Creating and Using Classes
public class BankAccount{
Chapter Three - Implementing Classes
The Basics of Class Diagrams for a single class
Introduction to Objects
CS2011 Introduction to Programming I Objects and Classes
LESSON 4-2 Posting from a General Journal to a General Ledger
JAVA CLASSES.
Introduction to Object-Oriented Programming
By Rajanikanth B Classes in Java By Rajanikanth B
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Designing Classes Lab

The object that you brought to class Put it in the basket we will exchange them now

Designing a Class on your own Think – What is the responsibility of this class? (name it appropriately) – What functionality or behavior should it provide? (methods) – What state do the objects need to carry out their responsibilities? (attributes or fields or properties)

Example: Designing a BankAccount Class Think – What is the responsibility of this class? To define a bank account entity for purposes of managing bank accounts in a system. – What functionality or behavior should it provide? (methods) What does the bank account do? – What state do the objects need to carry out their responsibilities? (attributes) What does it need to know about itself? Bank Account: Every Bank Account must have a name (typically the owner), a unique account number, and a balance. It should provide methods to:  deposit or withdraw money  query the current balance  query the account name  print a neat one line summary of owner, account number, balance

Responsibility of a BankAccount Class Every Bank Account should provide methods to:  deposit or withdraw money  query the current balance  query the account name  print a neat one line summary of owner, account number, balance

Functionality a BankAccount Class Behavior:  deposit( amount ) : add money to the account balance  debit( amount ) : deduct money from the balance  getName( ) : return the account name (String)  getBalance( ) : return the current balance (double)

State of a BankAccount Class Looking at the required behavior, what attributes [or fields or properties] does a Bank Account object need?  balance : the current balance. We'll use type "double".  name : a String containing the account name.  accountID : the account ID. String or int or long? (Note: Account numbers are always 10-digits.) Behavior:  deposit( amount ) : add money to the account balance  debit( amount ) : deduct money from the balance  getName( ) : return the account name (String)  getBalance( ) : return the current balance (double)

Writing it all down: Class Diagram for a BankAccount Class BankAccount name accountID balance getBalance( ) deposit( double amount ) debit( double amount ) getName( ) A UML class diagram The methods = what it DOES The Class Name The attributes or state = what it KNOWS

In class exercise part 1 Look at your assigned object and identify – The responsibility – The functionality – And the attributes that it needs to carry out the functionality Write them down informally [like slide 4]

In class exercise part 2 Now make a class diagram from your thoughts in part 1 [like slide 8] We will present and discuss as many of these as possible in class.

Homework Your Turn: Do another class diagram at home. Take both of your class diagrams to the tutor [Spencer] in the lab [CLCC 385] to get his feedback and return your object to the basket. He will give you something [I’m not telling you what it is because you have to visit him to get it] and you will need to bring it to class next lab class. [Tuesdays are lecture; Thursdays are lab class] I will return your objects to you during the Thursday lab class next week. Spencer’s hours are posted on Blackboard in the announcements.