A Second Look at Classes and Objects. Contents A.Stock Purchase Problem B.Employee Problem C.Drawing Lines D.Exercises.

Slides:



Advertisements
Similar presentations
Inventory Management & Administration System Tourism suite A powerful computer software application handling carefully your inventory department activity.
Advertisements

1 Click to edit Master title style Budget A budget charts a course for a business by outlining the plans of the business in financial terms. 6-1.
©2012 Pearson Education, Inc. publishing as Prentice Hall 6-1 QUICKBOOKS® 2011: A COMPLETE COURSE CHAPTER 6—LECTURE PAYABLES AND PURCHASES: MERCHANDISING.
Checking Account Register
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Chapter 23 1.
GOALS BUSINESS MATH© Thomson/South-WesternLesson 12.1Slide Cash Sales and Sales on Account Complete a cash proof form Calculate sales invoice and.
© 2010 Prentice Hall Business Publishing, College Accounting: A Practical Approach, 11e by Slater Banking Procedure and Control of Cash Chapter 6.
Job Order Costing Systems
© 2010 Prentice Hall Business Publishing, College Accounting: A Practical Approach, 11e by Slater Notes Receivable and Notes Payable Chapter 14.
Copyright © 2014 Pearson Education, Inc. publishing as Prentice Hall
Tax Accounting.
McGraw-Hill/Irwin Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved.
Applications of Percent
7 - 1 ©2002 Prentice Hall, Inc. Business Publishing Accounting, 5/E Horngren/Harrison/Bamber Internal Control, Managing Cash, and Making Ethical Judgments.
Chapter 3 Banking Services
Copyright © 2015, 2011, and 2007 Pearson Education, Inc. 1 Chapter 12 Business and Consumer Loans Section 1 Open-End Credit and Charge Cards.
Do Now 4/12/11 Take out HW from last night. Take out HW from last night.  Text p. 365, #8-16 evens and #15 Copy HW in your planner. Copy HW in your planner.
Warm Up Write the percent as a fraction and decimal 5% 6% 12% 6.5% 8%
Unit 03: Financial Literacy Vocabulary. Available Balance The amount available in an account for a person, business, or organization to spend. How much.
Do Now 4/23/10 Take out HW from last night. Take out HW from last night. Practice worksheet 7.6 odds Practice worksheet 7.6 odds Copy HW in your planner.
Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan.
Indicator 4.05 Process sales documentation. Identify types of information contained in sales documentation The document types can be tailored to meet.
ACCT 2310 Accounting Principles I Chapter 2 Dr. Robert R. Oliva Professor and Chairperson Department of Accounting University of Arkansas at Little Rock.
©2003 Prentice Hall Business Publishing, Cost Accounting 11/e, Horngren/Datar/Foster Cost-Volume-Profit Analysis Chapter 3.
Text Processing and More about Wrapper Classes. Contents I.The Test Score Problem II.Exercise.
Copyright 2010, The World Bank Group. All Rights Reserved. Introduction to the System of National Accounts (SNA) Lesson 9 Data Sources for Estimating GDP.
Recording Transactions in a General Ledger. Journal – a form for recording transactions in chronological order. Journaling – recording transactions in.
Product/Service & Distribution P.O.S. System Nick Mercuro, Evan Klipple, Austin Moore.
Fixed Assets: Asset disposal.
Needles Powers Principles of Financial Accounting 12e Accounting for Merchandising Operations 6 C H A P T E R ©human/iStockphoto.
©2002 Prentice Hall, Inc. Business Publishing Accounting, 5/E Horngren/Harrison/Bamber Current Liabilities and Payroll Chapter 11.
UNIT E SELLING FASHION 5.03 Perform various mathematical calculations in retail sales.
5 Minute Check Complete in your notes. MegaMart collects a sales tax equal to 1/16 of the retail price of each purchase. The tax is sent to the government.
Chapter 8 Classes and Objects: A Deeper Look. The Time Object.
Copyright © 2007 SaiGon Tech 1. 2 Contents A.Overview of the Sequential Structure B.Decision Structures C.Decision Structure Examples.
A Second Look at Classes and Objects. Contents A.Stock Purchase Problem B.Employee Problem C.Drawing Lines D.Exercises.
Chapter 22: Accounting for Inventory By: Audrey Marshall.
Chapter 10 Object-Oriented Programming: Polymorphism.
POS Order Process Jennifer Perez Jun Park. Merchant Application Service Agreement Voided Check or Bank letter Two forms of business ID Copies of two consecutive,
24 - 1©2002 Prentice Hall, Inc. Business Publishing Accounting, 5/E Horngren/Harrison/Bamber Flexible Budgets and Standard Costs Chapter 24.
CENTURY 21 ACCOUNTING © Thomson/South-Western 1 LESSON 5-1 PART II: ACCOUNTING ADJUSTMENTS AND VALUATION Overview: Intro to accounting procedures and their.
Managing Money 4.
Chapter 36 Financing the Business Section 36.1 Preparing Financial Documents Section 36.2 Financial Aspect of a Business Plan Section 36.1 Preparing Financial.

Copyright © 2015 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
Regular Expressions.
Internationalization The Number Format Problem
Calculating interest You can calculate the time value of your savings by figuring out how much interest you will earn. Principal – the original amount.
Managerial Accounting Second Edition Weygandt / Kieso / Kimmel
Personal Financial Management
National 4/5 Business Management
Operating Budgets Manufacturing Budgets
Operating Budgets: Manufacturing Budgets
Lifo Periodic 200 $9 Jan. 1 Beginning Inventory 300 $10
Job Order and Process Costing
LESSON 6-1 The Nature of Merchandise Inventory
Bell Work From 5 to = 5 40% increase
LESSON 19-1 Determining the Quantity of Merchandise Inventory
Section 13-2 Consumer Credit.
Chapter 3 Banking Services
Chapter 36 Financing the Business
Agricultural Microeconomics Lesson 7: Intro to Spreadsheet Modeling
Welcome Back Atef Abuelaish.
© 2009 Cengage Learning. All rights reserved.
Operating Budgets Manufacturing Budgets
Percent, %.
Resource Planning Chapter 16
Do Now 4/11/11 Take out HW from last night. Copy HW in your planner.
© 2008 Pearson Addison-Wesley. All rights reserved
Presentation transcript:

A Second Look at Classes and Objects

Contents A.Stock Purchase Problem B.Employee Problem C.Drawing Lines D.Exercises

A. Stock Purchase Problem A stock purchase consists of info of a stock and number of shares Info of a stock includes the trading symbol and share price –Trading symbol is a short series of characters that are used to identify the stock on the stock exchange Develop a program to calculate the cost of a stock purchase, given that cost = number-of shares × share-price

Solution 1.Design 2.Test Case 3.Developing Test Class 4.Fixing Test Class

1. Design

2. Test Case Input: –Stock Trading symbol: XYZ Share price: $9.62 –Number of shares: 100 Output: $962.0

3. Developing Test Class

4. Fixing Test Class 4.1. Creating Class Stock 4.2. Creating Class StockPurchase 4.3. Running Test Class To See Red Bar 4.4. Changing delta in Test Method

4.1. Creating Class Stock

4.2. Creating Class StockPurchase

4.4. Changing delta in Test Method

B. Employee Problem Info of an employee includes: first name, last name, birthday, and hire day. Develop the Employee class

Solution 1.Design 2.Test Cases 3.Developing Test Class 4.Fixing Test Class

1. Design

A Better Design

An Even Better Design

2. Test Cases Example 1 –Personal Info Name –First name: Sue –Last name: Jones Birthday: Sept 5, 1986 –Hire day: Jan 1, 2007 Example 2 –Personal Info Name –First name: Bob –Last name: Blue Birthday: July 24, 1949 –Hire day: March 12, 1988

3. Developing Test Class

4. Fixing Test Class Develop PersonalInfo  Develop class Name Handling Date

 Develop static factory method makeDate()

Develop Class Employee

C. Drawing Lines 1. Drawing Random Lines 2. Drawing a Flower

1. Drawing Random Lines Draw a random number of lines (at least 1 and at most 5) inside a frame

2. Drawing a Flower

D. Exercises 1.The Savings Account Problem 2.The Course Problem 3.The Sports Car Problem 4.The Retail Problem 5.The Parking Problem

1. The Savings Account Problem A savings account has a balance indicating the amount the saver currently has on deposit. The bank applies the same annual interest rate for all account holders Develop a program that has the following behaviors –Setting a new value for the annual interest rate –Calculating the monthly interest (by multiplying the balance by the annual interest rate divided by 12) –Updating the balance monthly by adding the monthly interest to the current balance Test your program with two savings accounts with balances of $ and $ In the beginning, the annual interest rate is 4%. After a month, the annual interest rate is changed to 5%

2. The Course Problem A course holds the following information: –The course name –The instructor’s last name, first name, and office number –The textbook’s title, author, and publisher

3. The Sports Car Problem A sports car has the following information: –The type (make) –The color –The price The type is either Porsche, Ferrari, or Jaguar The color is either red, black, blue, or silver

4. The Retail Problem An item in a retail store holds the following information –A brief description of the item –The number of units currently in inventory –The item’s retail price For example DescriptionUnits on HandPrice Item #1Jacket Item #2Designer Jeans Item #3Shirt

A cash register is a sale of a retail item Given the quantity of items being purchased, the cash register provides the sale’s subtotal, amount of sales tax, and total –The subtotal is the quantity multiplied by the price –The sales tax rate is 6% of a retail sale –The total is the subtotal plus the sales tax

5. The Parking Problem This problem is about a police officer issuing a parking ticket A parked car holds the following information –The car’s make (for example Toyota) –The model (for example, Nissan Z28) –The color –The license number (for example XY-1234) –The number of minutes that the car has been parked A parking meter records the number of minutes of parking time that has been purchased A parking ticket is responsible for –Reporting the make, model, color, and license number of the illegally parked car –Reporting the amount of the fine, which is $25 for the first hour or part of an hour that the car is illegally parked, plus $10 for every additional hour or part of an hour that the car is illegally parked –Reporting the name and badge number of the police officer issuing the ticket A police officer inspecting parked cars is responsible for –Telling his/her name and badge number –Examining the parked car and the parking meter, and determining whether the car’s time has expired –Issuing a parking ticket if the car’s time has expired

References 1.Java How to Program, Seventh Edition, Chapter 8. Deitel & Deitel, Starting Out with Java, Chapter 9. Tony Gaddis and Godfrey Muganda, Core Java, Volume II – Advanced Features, Eighth Edition, Chapter 1. Cay S. Horstmann & Gary Cornell. Prentice Hall, 2008