private double amountFor(Rental aRental)

Slides:



Advertisements
Similar presentations
Higher-Order Functions and Loops c. Kathi Fisler,
Advertisements

***** SWTJC STEM ***** Chapter 4-1 cg 42 Object Oriented Program Terms Up until now we have focused on application programs written in procedural oriented.
Refactoring This lecture is divided into and introduction to refactoring and then several lessons. The intent is not to teach you all the refactorings.
Software Testing and Maintenance 1 Today’s Agenda  Course Evaluation  HW 4 Return  HW 5 Correction  Quiz 4 Next Class  Software Refactoring.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Refactoring Software Engineering Refactoring Software Engineering 2011 Department of Computer Science Ben-Gurion university Based on slides of: Mira Balaban.
CS Data Structures Appendix 1 How to transfer a simple loop- expression to a recursive function (factorial calculation)
A Small Exercise Suppose you need to implement a movie rental system Your movie rental system must deal with Three kind of movie rental Three kind of movie.
Scripting Languages Perl Chapter #4 Subroutines. Writing your own Functions Functions is a programming language serve tow purposes: –They allow you to.
Access 2007 ® Use Databases How can Access help you to find and use information?
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Methods and You. Up to this point, I have covered many different data types with you. Variables can be considered the nouns of an English sentence. If.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Java Classes Methods Objects. Classes Classes We have been using classes ever since we started programming in Java Whenever we use the keyword class.
Class Example - Rationals Rational numbers are represented by the ratio of two integers, a numerator and a denominator, e.g., 2/3. This is opposed to irrational.
Refactoring Software Engineering Refactoring Software Engineering 2012 Department of Computer Science Ben-Gurion university Based on slides of: Mira Balaban.
CS4723 Software Engineering Lecture 12 Software Design Quality.
5 or more raise the score 4 or less let it rest
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Introduction to MVC Controllers NTPCUG Tom Perkins, Ph.D.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Today’s Agenda  More refactoring patterns Software Testing and Maintenance 1.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Network Address Translation External/ Internal/. OVERLOADING In Overloading, each computer on the private network is translated to the same IP address;
Refactoring. Announcements HW7 due today, HW8 coming up tomorrow (I’m taking a late day on posting HW8) Grades and feedback for HW0-5 in Homework Server.
Week 5 U8 United Soccer of Auburn Topic: Defending.
CSI 3125, Preliminaries, page 1 Class. CSI 3125, Preliminaries, page 2 Class The most important thing to understand about a class is that it defines a.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 10 More on Objects and Classes.
CS 139 Objects Based on a lecture by Dr. Farzana Rahman Assistant Professor Department of Computer Science.
Introduction to Programming in Corvid EXSYS-Corvid is an intelligent systems programming environment General order of tasks: Enter and define Variables.
1 Introduction to Object Oriented Programming Chapter 10.
Refactoring. DCS – SWC 2 Refactoring ”A change made to the internal structure of software to make it easier to understand and cheaper to modify without.
Refactoring Improving code after it has been written.
Invoking methods in the Java library. Jargon: method invocation Terminology: Invoking a method = executing a method Other phrases with exactly the same.
Section 8.4 Mathematical Induction. Mathematical Induction In this section we are going to perform a type of mathematical proof called mathematical induction.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Review for Test2. Scope 8 problems, 60 points. 1 Bonus problem (5 points) Coverage: – Test 1 coverage – Exception Handling, Switch Statement – Array of.
Chapter 8: Understanding Collections Textbook: Chapter 4.
Refactoring (1). Software Evolution Cope with change Feature bloat Design decay Code duplications “Pattern time is refactoring time” Make future changes.
A (Very) Simple Example Consolidate duplicate conditional fragments if (isSpecialDeal()) { total = price * 0.95; send (); } else { total = price * 0.98;
Chapter 6 Persistence-Saving and Retrieving Data
Design Skills Example.
User-Written Functions
Module Road Map Refactoring Why Refactoring? Examples
Expressions With Substitution
Chapter 9 More on Objects and Classes
Outline A. What is Refactoring? B. Why do we Refactor?
Functions CIS 40 – Introduction to Programming in Python
Online Gifts Buy for wishes happy mother's day to yours choice and with happy gifts find here:
Graph Paper Programming
Chapter 7: Macros in SAS Macros provide for more flexible programming in SAS Macros make SAS more “object-oriented”, like R Not a strong suit of text ©
Refactoring.
Graph Paper Programming
Reusability 11/29/2018© 2006 ITT Educational Services Inc.
Chapter 9 Objects and Classes
Context Level DFD Video Purchase System Video Information Management
10:00.
Nate Brunelle Today: Functions again, Scope
Array and Method.
Workshop for Programming And Systems Management Teachers
Strip me.
Unit 3 Review (Calculator)
right angle acute obtuse How to measure angles using a protractor
Unit 3 Lesson 1 Part 2 Multiplying and Dividing Radicals
½ of 6 = 3.
Computer Organization and Assembly Language
python
Day 11 The Last Week!.
Presentation transcript:

private double amountFor(Rental aRental) return aRental.getCharge(); } initially replace the body with the call remove this method later on and call directly while (rentals.hasMoreElements()) { double thisAmount = 0; Rental each = (Rental) rentals.nextElement(); thisAmount = each.getCharge(); … the rest continues as before

frequent renter points Let’s do the same thing with the logic to calculate frequent renter points extract method each can be parameter frequentRenterPoints has a value before the method is invoked, but the new method does not read it; we simply need to use appending assignment outside the method. move method Again, we are only using information from Rental, not Customer, so let’s move getFrequentRenterPoints to the Rental class. Be sure to run your test cases after each step

// add frequent renter points // add bonus for two day new release rental if ((each.getMovie().getPriceCode() == Movie.NEW_RELEASE) && each.getDaysRented() > 1) // show figures for this rental result += “\t” + each.getMovie().getTitle() + “\t” + String.valueOf(thisAmount) + “\n”; totalAmount += thisAmount; } // end while