8 Pages

lect06-ece122_spring08

Course: ECE 122, Fall 2009
School: UMass (Amherst)
Rating:
 
 
 
 
 

Word Count: 952

Document Preview

122 ECE Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation ECE122 L6: Problem Definition and Implementation February 14, 2008 Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking the problem into pieces Writing needed classes and methods Additional Java stuff Encapsulation, private/public, conditionals ECE122 L6: Problem...

Register Now

Unformatted Document Excerpt

Coursehero >> Massachusetts >> UMass (Amherst) >> ECE 122

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
122 ECE Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation ECE122 L6: Problem Definition and Implementation February 14, 2008 Outline Problem: Create, read in and print out four sets of student grades Setting up the problem Breaking the problem into pieces Writing needed classes and methods Additional Java stuff Encapsulation, private/public, conditionals ECE122 L6: Problem Definition and Implementation February 14, 2008 Encapsulation Two views of an object: internal - the details of the variables and methods of the class that defines it external - the services that an object provides and how the object interacts with the rest of the system From the external view, an object is an encapsulated entity Provides a set of specific services These services define the interface to the object ECE122 L6: Problem Definition and Implementation February 14, 2008 Encapsulation One object (called the client) may use another object for the services it provides The client of an object may request its services (call its methods) Should not have to be aware of how those services are accomplished Any changes to the object's state (its variables) should be made by that object's methods ECE122 L6: Problem Definition and Implementation February 14, 2008 Encapsulation An encapsulated object can be thought of as a black box Inner workings are hidden from the client The client invokes the interface methods of the object, which manages the instance data Client Methods Data ECE122 L6: Problem Definition and Implementation February 14, 2008 Visibility Modifiers Accomplish encapsulation through the appropriate use of visibility modifiers A modifier is a Java reserved word Specifies particular characteristics of a method or data The final modifier to define constants Java has three visibility modifiers: public, protected, and private The protected modifier will be discussed later ECE122 L6: Problem Definition and Implementation February 14, 2008 Visibility Modifiers Members of a class that are declared with public visibility can be referenced anywhere Members of a class that are declared with private visibility can be referenced only within that class Members declared without a visibility modifier have default visibility Can be referenced by any class in the same package ECE122 L6: Problem Definition and Implementation February 14, 2008 Visibility Modifiers Methods that provide the object's services are declared with public visibility They can be invoked by clients Public methods are also called service methods A method created simply to assist a service method is called a support method Support method should be declared with private visibility ECE122 L6: Problem Definition and Implementation February 14, 2008 Visibility Modifiers public Variables private Enforce encapsulation Support other methods in the class Violate encapsulation Provide services to clients Methods ECE122 L6: Problem Definition and Implementation February 14, 2008 Accessors and Mutators Instance data is usually private A class usually provides services to access and modify data values An accessor method returns the current value of a variable A mutator method changes the value of a variable The names of accessor and methods mutator often take the form getX and setX X is the name of the value They are sometimes called getters and setters ECE122 L6: Problem Definition and Implementation February 14, 2008 Mutator Restrictions The use of mutators restricts modifications to an objects state A mutator is often designed so that the values of variables can be set only within particular limits Example: setFaceValue mutator of the Die class should have restricted the value to the valid range (1 to MAX) ECE122 L6: Problem Definition and Implementation February 14, 2008 Bank Account Example Example that demonstrates the implementation details of classes and methods Well represent a bank account by a class named Account Its state can include the account number, the current balance, and the name of the owner An accounts behaviors (or services) include deposits and withdrawals, and adding interest ECE122 L6: Problem Definition and Implementation February 14, 2008 Bank Account Example acct1 acctNumber 72354 balance 102.56 name Ted Murphy acct2 acctNumber balance name 69713 40.00 Jane Smith ECE122 L6: Problem Definition and Implementation February 14, 2008 Constructors Note that a constructor has no return type specified in the method header, not even void A common error is to put a return type on a constructor Makes it a regular method that happens to have the same name as the class The programmer does not have to define a constructor for a class ECE122 L6: Problem Definition and Implementation February 14, 2008 // Account.java Author: Lewis/Loftus // Represents a bank account with basic services such as deposit and withdraw. //******************************************************************** Instance data. EACH object of import java.text.NumberFormat; public class Account. type Account will get its own { copy of these variables. private final double RATE = 0.035; // interest rate of 3.5% Note: all private. (means only private long acctNumber...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UMass (Amherst) - ECE - 669
Lecture1: Introduction1Administrative infoWelcome to ECE669! Welcome off-campus students! Csaba Andras Moritz, Associate Professor @ ECE/UMASS Questions/discussions/email questions are welcome! My Focus: Design of Parallel Computer SystemsChips
UMass (Amherst) - ECE - 669
L51Commercial Application Support21Commercial Application Support-Not in textbook! Commercial enterprise oriented applications are commonly run on SMP type of machines to achieve high throughputs High-end is considered to be more massive
RIT - SMAM - 314
SMAM 314 Computer Assignment 6 Due 5/15/07 I For the data of problem 6.11 p.391 (SeeTable 6.19) Using Minitab A. Make a scatterplotB. Fit the regression line.Regression Analysis: y versus x The regression equation is y = - 1822 + 435 x Predictor C
RIT - SMAM - 351
SMAM 351Homework 8 Solution1. A. Using the lack of memory property of the exponential distribution P[X < 0.7) = 0 .5e.5x dx = e.5x B. The number of customers that arrive each minute is a Poisson distribution with mean 5. The number that arrive in
RIT - SMAM - 314
p 1 of 9Information about SMAM 314-Dr. Gruber's Section Instructor: Dr. M. Gruber office 08-3250 Phone 475-2541 email mjgsma@rit.edu Web page http:/www.rit.edu/~mjgsma/smam314winter00/hw.html (The web page may also be found by going to my home page
RIT - SURGERY - 0308
Total Hip ReplacementBy Krystal Stephenshttp:/www.rit .edu/~kjs0308/Surgery2_072/Total%20hip%20replacement/Total_hip_replacement.htmWhat is Total Hip Replacement? A total hip replacement is a surgical procedure where the diseased cartilage and b
UMass (Amherst) - CHEM - 121
Chemistry 121H Fall, 2005 Name Cumulative Final Exam 170 points total Please sign the following statement: I swear that I did not cheat on this exam.ID#Electronegativities: F = 4.0; O = 3.5; N = 3.0; Cl = 3.0; Br = 2.8; C = 2.5; S = 2.5; I = 2.5;
UMass (Amherst) - CHEM - 241
RIT - JRW - 9428
James Wegner Frey Digital Asset Management 24 February 2007 Final Exam 1. Must separate format from content The main reasons for separating format from content are to keep your files organized. It is important to keep youre your content saved only on
BYU - LECT - 621
CS 521Nonparametric Methods - Metrics1Distance?What's more different? A big difference in just one feature? Smaller differences in two features? Lots of small differences? Lots of ways to measure "distance" than just Euclidean distance.CS
BYU - LECT - 621
CS 521Introduction to Neural Networks1Neural NetworksWhat? Combinations of simple processing units with inputs, output(s), and a function relating the two.Why? 1. Massive parallelism (connectionist computing) 2. Can model biological systems
UMass (Amherst) - CS - 601
CMPSCI 601:Turing MachinesLecture 4: nite set of states; : " ! 1 1 0 11&3 4! 20 1#5 5 765)('%# & $: nite set of symbols; 5 5 675 5 5 765 5 5 675 5 5 675 5 5 675 5 5 675 5 5 675 5 5
UMass (Amherst) - CS - 601
CMPSCI 601:Recall From Last TimeLecture 7Th 6.2: The busy beaver function, larger than any total, recursive function.Thm. 6.4: (Unsolvability of Halting Problem) Let,Then,HALT is r.e. but not recursive.Listing of all r.e. sets:Cor. 6.
UMass (Amherst) - CMPSCI - 201
CMPSCI 201 Spring 2004 Professor William T. VertsLecture #35 May 5, 2004 I Feel the Need for SpeedThere are a number of methods for increasing the throughput of a processor. The first and most obvious is to increase the raw clock speed. While
UMass (Amherst) - CS - 645
IntroductionHash-based indexes are best for equality selections. Cannot support range searches. E.g., retrieve a student with id 1234 or all students at 20.Hash-Based IndexesYanlei Diao UMass AmherstStatic and dynamic hashing techniques ex
UMass (Amherst) - CS - 445
Normalization26Evils of Redundancy When a database schema is poorly designed we get anomalies. Redundancy is at the root of several problems associated with relational schemas:Redundant storage: data is repeated Update anomalies: need to chang
UMass (Amherst) - CS - 445
Access Methods and Sorting for Query ProcessingYanlei Diao UMass Amherst March 4, 2008Slides Courtesy of R. Ramakrishnan and J. Gehrke1OutlineComparing access methods External sorting2Comparing Access MethodsHeap file: random order Sorte
UMass (Amherst) - CS - 445
CMPSCI445 Information SystemsProf. Yanlei DiaoUniversity of Massachusetts AmherstOutline Overview of databases and DBMS Course topics Course requirementsYanlei Diao, University of Massachusetts Amherst1/29/2008DatabaseDatabaseDatabas
UMass (Amherst) - CS - 645
Overview of Storage and IndexingCMPSCI 645 Feb 28, 2008Slides Courtesy of R. Ramakrishnan and J. Gehrke1DBMS ArchitectureQuery Parser Query Rewriter Query Optimizer Query ExecutorFile & Access MethodsLock ManagerLog ManagerBuffer Mana
UMass (Amherst) - CS - 645
645: Database Design and ImplementationYanlei DiaoUniversity of Massachusetts AmherstOutline Overview of databases and DBMSs Course topics and requirementsYanlei Diao, University of Massachusetts Amherst2/4/09Databases and DBMSs A databa
UMass (Amherst) - CS - 445
SQL, continued.CMPSCI 445 September 21, 2006Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu.SQL Overview Query capabilities SELECT-FROM-WHERE blocks, Basic features, ordering, duplicates Set ops (union, intersect, except)
UMass (Amherst) - CS - 445
SQL, continued.CMPSCI 445 September 19, 2006Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu.SQL Overview Query capabilities SELECT-FROM-WHERE blocks, Basic features, ordering, duplicates Set ops (union, intersect, except)
UMass (Amherst) - CS - 445
Tree-Structured IndexesYanlei Diao UMass Amherst Feb 28, 2007Slides Courtesy of R. Ramakrishnan and J. Gehrke1B+ Tree: Most Widely Used IndexHeight-balanced given arbitrary inserts/deletes.Fanout: # child pointers of a non-leaf node F = avg.
UMass (Amherst) - MATH - 233
Math 233Practice Exam 2Fall 20051. Find the critical points of f (x, y) = x3 + y 2 + 2xy 4x 3y + 5 and classify each as a relative maximum, relative minimum or saddle point. 2. An open (no top) rectangular box must have a volume of 6 cubic fe
UMass (Amherst) - MATH - 697
Homework Problems1) Consider the model utt = uxx + 2(u - u3 ) 1. For traveling wave solutions u(x, t) = f (x - ct) with c2 < 1, set up the relevant ODE and find the corresponding potential, and phase plane representation of the solutions. 2. For di
Concordia Chicago - ACE - 104
Copyright (c) [2002]. Roger L. Costello. All Rights Reserved.1REST (Representational State Transfer)Roger L. Costello XML Technologies CourseCopyright (c) [2002]. Roger L. Costello. All Rights Reserved.2Acknowledgements I would like to th
East Los Angeles College - PHY - 221
M Grell, PHY221 2008/09 Semester 1 Problems class questions Sheet 1 1. Show that the two representations of harmonic oscillations:x(t) = A sin 0t + B cos 0t and x(t) = X max cos( 0t + )are equivalent. Express Xmax, in terms of A,B, as simply a
UMass (Amherst) - SOM - 541
Sch-Mgnt 541 Auditing Assignment PacketChapter 6 End-of-Chapter materials in the Ricchiute textbook Problems and Discussion Cases: 6-2 6-6 6-7 6-13 Financial Statement Assertions Analytical Procedures Applying Analytical Procedures Cognitive Heuris
East Los Angeles College - PHY - 221
PHY221, Martin Grell 2008/09, Semester 1 Problems Class Questions Sheet 2 1 a.) Given a point in cylindrical coordinates (,z), express it in Cartesian coordinates. (Define = 0 for x direction). [1] b.) Given a point in spherical coordinates (r,), ex
Concordia Chicago - ACE - 104
WSDLHomeworkPlenioWSDLStructureSource: w3schools.comWSDLNamespacesnamespaces in the wsdlWSDLTypesdefines the xml types define or include schemaWSDLTypesWSDLMessagesthe input and output messages that are being exchangedWSDLPortTypesd
Concordia Chicago - ACE - 104
WSDL 1<!- SOAP Request Document/Literal Message -><?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAPENV="http:/schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <PaymentScheduleRequest xmlns="http:/www.cccis
Concordia Chicago - ACE - 104
WSDL 3<!- SOAP Request Document/Literal Message -><?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAPENV="http:/schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <RealEstateRequest xmlns="http:/www.cccis.com/
Concordia Chicago - CSPP - 51038
Homework 3Due July 30Redo homework 2 using some DOM model in some language.
Colorado - AMATH - 2360
APPM 2360Differential EquationsSpring 2008Lecture 010, MWF 8:008:50 AM, ECCR 150 Terry Haut, STAD 152, (303) 735 3610 terry.haut@colorado.edu Office Hours: MWF 9:30-10:30 AM Lecture 030, MWF 2:002:50 PM, ECCR 265 Theodoros Horikis, ECCR 251, (3
Concordia Chicago - CSPP - 51038
Copyright (c) [2002]. Roger L. Costello. All Rights Reserved.1REST (Representational State Transfer)Roger L. Costello XML Technologies CourseCopyright (c) [2002]. Roger L. Costello. All Rights Reserved.2Acknowledgements I would like to th
Concordia Chicago - CSPP - 51038
XML Simple TypesCSPP51038 shortcourseSimple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements with text and no attributes are of simple type Careful: Elements with text and attributes a
Concordia Chicago - CSPP - 51038
Parsing XML into programming languagesJAXP, DOM, SAX, JDOM/DOM4J, Xerces, Xalan, JAXBParsing XML Goal: read XML files into data structures in programming languages Possible strategies Parse by hand with some reusable libraries Parse into gen
Concordia Chicago - CSPP - 51038
XML Simple TypesCSPP51038 shortcourseSimple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements with text and no attributes are of simple type Careful: Elements with text and attributes a
Concordia Chicago - CSPP - 58001
Due Monday, April 13 5PMFloating Point/Matlab warmupFor each of the following, show all of your work. You do nothave to write any code.Assuming always normalized form:1. Work out the minimum and maximum values of an ieee doubleprecision floa
Concordia Chicago - LESSON - 58001
Due Monday, April 13 5PMFloating Point/Matlab warmupFor each of the following, show all of your work. You do nothave to write any code.Assuming always normalized form:1. Work out the minimum and maximum values of an ieee doubleprecision floa
Concordia Chicago - CSPP - 58001
Covered: 1. floating point representation with focus on ieee standard 2. Basic intro to matlab 3. Intro to concepts or 1d root finding (to be continued)Readings: Numerical Recipes ch. 8Homework: assigned and included in this directory
Concordia Chicago - LESSON - 58001
Covered: 1. floating point representation with focus on ieee standard 2. Basic intro to matlab 3. Intro to concepts or 1d root finding (to be continued)Readings: Numerical Recipes ch. 8Homework: assigned and included in this directory
UMass (Amherst) - PHIL - 110
Rules Introduced Day 1INTRO LOGICDAY 25Ov[v] [o] OLD name[o] v[v] OLD nameIDerivations in PL 41a name counts as OLD precisely if it occurs somewhere unboxed and uncancelled3OverviewExam 1 Exam 2 Exam 3 Exam 4 6 derivations Exam
Concordia Chicago - CSPP - 51038
Quiz 1CSPP53025April 7, 20041. What is the difference between a "well-formed" and a "valid" XML document?2. What is the role of an XML parser?3. What is an advantage of using XML vs. html to talk to a web browser?4. What is a disadvant
Concordia Chicago - CSPP - 51038
Quiz2Create a sample XML file that is valid according to following schema:<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http:/www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"><xs:element
Concordia Chicago - CSPP - 51038
CSPP53025Quiz 31. In the SAX parser model, what does the additional (second) argument to the parse method represent?2) Name two potential advantages of using DOM vs. SAX3) Name two potential advantages of using SAX vs. DOM4) Order the fol
Concordia Chicago - CSPP - 51038
1. Write an equivalent, simpler version of this xsl program.<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http:/www.w3.org/1999/XSL/Transform" xmlns:xsi="http:/www.w3.org/2001/XMLSchema-instance"><xsl:template ma
Colorado - AMATH - 2350
APPM 2350FINALFALL 2003On the front of your bluebook, print your name, student number, the name of your instructor and a grading table. The grading table should be numbered from 1 to 7. Apart from problem 1 (for which you should give only the a
BYU - DEG - 216
0 -> -o1 -> /raid/htdocs/deg/demos/live_demo/demo/default_data/defaultontsrc/book.ont2 -> -p3 -> /raid/htdocs/deg/demos/live_demo/user_data/deg216_164_140_107/am/4 -> -n5 -> 10006 -> -r7 -> /raid/htdocs/deg/demos/live_demo/ontology/ontology8
UMass (Amherst) - CS - 383
Lecture 10: Logical Agents & Propositional LogicCMPSCI 383: Artificial Intelligence Instructor: Shlomo ZilbersteinLogical Reasoning Example! !!!!Vincent has been murdered, and Arthur, Bertram, and Carleton are suspects. Arthur says he did
UMass (Amherst) - CS - 383
Todays lecture Lecture 9: Adversarial SearchCMPSCI 383: Artificial Intelligence Instructor: Shlomo Zilberstein!! ! ! ! !Competitive multi-agent environments modeled as games Adversarial search techniques The minimax algorithm Alpha-Beta pruning
UMass (Amherst) - CS - 383
Todays lecture Lecture 4: Local SearchCMPSCI 383: Artificial Intelligence Instructor: Shlomo Zilberstein! ! ! !Local search algorithms Hill-climbing Simulated annealing Genetic algorithms1Shlomo Zilberstein University of Massachusetts2Lo
UMass (Amherst) - CS - 383
Todays lecture Lecture 13: Inference in FOLCMPSCI 383: Artificial Intelligence Instructor: Shlomo Zilberstein! !Knowledge representation in FOL Matching rules and facts using unification Inference procedures: forward-chaining, backward-chaining,
UMass (Amherst) - CS - 383
Todays lecture Lecture 7: Abstraction and Hierarchical SearchCMPSCI 383: Artificial Intelligence Instructor: Shlomo Zilberstein! ! ! ! !Where do heuristics come from? Generating heuristics using abstraction Using abstraction to speedup search Hie
UMass (Amherst) - CS - 383
Lecture 11: Reasoning in Propositional LogicCMPSCI 383: Artificial Intelligence Instructor: Shlomo ZilbersteinToday's lecture! ! ! !Reasoning in propositional logic Theorem proving using satisfiability Forward and backward chaining Theorem prov
Concordia Chicago - CSPP - 51038
Last Abraham Abram Ahmad Alcantar Alexander Bauska Benson Bishof Bishop Brocker Bryce Carroll Cherian Clark Cousins Cross Dantes Davis Davis Dewitt Dickinson Discepola Dugan Ellenberger Finn Fuchs Galassi Gershenson Gholson Gomez Hanrahan Holtzman Ho
Concordia Chicago - CSPP - 51036
Final AssignmentTime: one weekYou will write an end-user banking application that manages a list of borrowers.The application will support the following commands:supported commands: add, query, remove, edit help, set, exitEach is described in
Concordia Chicago - CSPP - 51038
This application is generally designed to parse an XML document and display its data in a text file. It is specifically designed to parse the included document: "musical.xml". An XML Schema document called "musical.xsd" is also included and may be
McGill - COMP - 652
COMP 652: Assignment 5 Solutions1. K-MeansThere are 6 nal clusters; the centers, and corresponding number of elements, are: (241.2296, 238.6252, 233.8629) 4930 (194.4116, 136.3331, 90.9436) 15190 (136.2656, 61.0897, 10.1039) 52535 (157.2917
Colorado - MATH - 1300
WORKSHEET 12MATH 1300November 13, 2008Goal: To study the area under a curve without directly using the area function A(x). 1. The United States Postal Service used to charge postage for a first class domestic letter as follows: The postage was
Berkeley - EE - 105
EECS 105 Microelectronic Devices and CircuitsSpring 2001, Prof. A. R. Neureuther Dept. EECS, 510 Cory 642-4590 UC Berkeley Office Hours M11, (Tu2), W2, Th2, F11 Course Web Site http:/www-inst.EECS.Berkeley.EDU/~ee105/First Midterm Exam, February