COMP 110: Introduction to Programming Tyler Johnson Feb 25, 2009 MWF 11:00AM-12:15PM Sitterson 014.

Slides:



Advertisements
Similar presentations
Artrelle Fragher & Robert walker. 1 you look for the median 1 you look for the median 2 then you look for the min and max 2 then you look for the min.
Advertisements

COMP 110: Introduction to Programming Tyler Johnson Feb 11, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 18, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 16, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 23, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 20, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 13, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 26, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 23, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 12, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Mar 25, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 8, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 1, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson January 28, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming
COMP 110: Introduction to Programming Tyler Johnson Mar 2, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Apr 27, 2009 MWF 11:00AM-12:15PM Sitterson 014.
COMP 110: Introduction to Programming Tyler Johnson Feb 4, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Covert Barcodes handle on-the-spot Brand and Document Authentication Information Management Institute Conference on Security Printing 11/18/2009 Read what.
2010 Tax Class1 Day 3 Class Participation Class Exercise – Paul Austin Publ W Exercise page 98 Advanced Section.
Tax Year TYPES OF PAYMENTS 1040 PG 2 Line & 68 Federal income tax withheld from W-2s, 1099s Estimated payments & $ applied from prior year.
Final and Abstract Classes
1 Inheritance Classes and Subclasses Or Extending a Class.
Large Scale Integration of Senses for the Semantic Web Jorge Gracia, Mathieu dAquin, Eduardo Mena Computer Science and Systems Engineering Department (DIIS)
M. Mayer SEWG Fuel Retention June Sample Analysis for TS, AUG and JET: Depth Profiling of Deuterium M. Mayer Max-Planck-Institut für Plasmaphysik,
Producing monthly estimates of labour market indicators exploiting the longitudinal dimension of the LFS microdata R. Gatto, S. Loriga, A. Spizzichino.
NOTEBOOKS ACCEPTABLE or NOT? March THINGS TO REMEMBER Must be Specific to the child. Consistent with the needs of the individual student. Personal.
Half Life. The half-life of a quantity whose value decreases with time is the interval required for the quantity to decay to half of its initial value.
1 1  1 =.
1  1 =.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 4 : Polymorphism King Fahd University of Petroleum & Minerals College of Computer.
Wouter Noordkamp The assessment of new platforms on operational performance and manning concepts.
Student Learning Center Time Management Welcome to the Time Management workshop. While we are waiting to begin, please fill out the blank weekly.
Ziehm Academy - User Guide for online registration portal Nuremberg, February 2009.
October FUEL PRICE EVALUATION Comparing different fuel costs is a complex issue requiring an in-depth knowledge of fuel properties and characteristics,
Least Common Multiple (LCM)
Automation Solutions for Ladle Gate Applications
Intro to CS – Honors I More Objects and Methods GEORGIOS PORTOKALIDIS
Efficient Solutions For Water Supply Helix High-Pressure Vertical Multistage Pump.
Speed Limit Finder CS 410 Fall 2009 Personal Presentation September 21, 2009 Sept. 21,
1 Cathay Life Insurance Ltd. (Vietnam) 27/11/20091.
ATUG Roundtable – November 2009 NBN Architecture Reference Model.
1 User-Defined Classes The String class is a pre-defined class that is provided by the Java Designer. Sometimes programmers would like to create their.
1 Review Quisioner Kendala: Kurang paham materi. Praktikum Pengaruh teman.
1. (c) Alan Rowley Associates Laboratory Accreditation Dr Alan G Rowley Quality Policy based on Quality Objectives Quality Management System Communicate.
Vault 9 Project Update 9 th September 2009 Paul Pointon – Site Project Delivery Manager LLW Repository Ltd.
30 min Scratch July min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)
Number bonds to 10,
Beat the Computer Drill Divide 10s Becky Afghani, LBUSD Math Curriculum Office, 2004 Vertical Format.
CHAPTER 11 FILE INPUT & OUTPUT Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Panel 3D = XML file pointer 08/09/20091 LHCb calorimeter meeting (jean-luc PANAZOL)
Flexible Scheduling of Software with Logical Execution Time Constraints* Stefan Resmerita and Patricia Derler University of Salzburg, Austria *UC Berkeley,
01. Consider the following code segment. int x = int n = 0; if (x < 500) { if (x > 750) n = 100; else n = 200; } else { if (x < 300) n = 300; else n =
COMP 110 Objects and References Tabitha Peck M.S. February 27, 2008 MWF 3-3:50 pm Philips
Constructors. Defining Constructors  A constructor is a special kind of method that is designed to perform initializations, such as giving values to.
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
COMP 110 Constructors Luv Kohli October 13, 2008 MWF 2-2:50 pm Sitterson 014.
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
COMP 110: Introduction to Programming Tyler Johnson Feb 16, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Catie Welsh March 23,  Lab 6 due Friday by 1pm 2.
COMP 110 Designing and overloading methods Luv Kohli November 3, 2008 MWF 2-2:50 pm Sitterson 014.
COMP 110 More about classes Luv Kohli October 3, 2008 MWF 2-2:50 pm Sitterson 014.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Questions? Math Class Wrapper Classes Writing / Testing Methods.
Announcements Program 2 is due tomorrow by noon Lab 4 was due today
Announcements Lab 5 was due today Program 3 due Monday by 12pm
More About Objects and Methods Chapter 5 Programming with Methods
Presentation transcript:

COMP 110: Introduction to Programming Tyler Johnson Feb 25, 2009 MWF 11:00AM-12:15PM Sitterson 014

COMP 110: Spring Announcements Lab 5 due tomorrow by midnight Extending Program 3 to Monday by 5pm A sample midterm has been posted

COMP 110: Spring Questions?

COMP 110: Spring Lab 4

COMP 110: Spring Program 3

COMP 110: Spring Today in COMP 110 In-Class Exercise Constructors

COMP 110: Spring In-Class Exercise Work in Groups

COMP 110: Spring Constructors Section 6.1 in text

COMP 110: Spring Creating Objects Student jack = new Student(); Why does this look like a method call? Because it is This is a call to a special method called a constructor

COMP 110: Spring Constructors A constructor is a special method that is called when an object is created using new The purpose of a constructor is to perform initializing actions e.g. initialize the instance variables of an object

COMP 110: Spring Constructors The purpose of a constructor is similar to that of a mutator (setter) Used to set the value of variable(s) However, constructors create an object in addition to initializing it

COMP 110: Spring Example: Pet class public class Pet { private String name; private int age; private double weight; public Pet() { name = No name yet.; age = 0; weight = 0; } public Pet(String initName, int initAge, double initWeight) { name = initName; age = initAge; weight = initWeight; }

COMP 110: Spring Constructors A constructor must have the same name as its class The constructor for the class Pet is Pet() The constructor for the class Student is Student() Constructors do NOT specify a return type Not even void

COMP 110: Spring Constructors The classes you have used up to this point use a constructor created automatically by Java Gives default values to instance variables May not be what you want You can specify how instance variables should be initialized by creating your own constructors

COMP 110: Spring Constructors w/ Parameters Like methods, constructors can have parameters public Pet(String initName, int initAge, double initWeight) { name = initName; age = initAge; weight = initWeight; }

COMP 110: Spring Default Constructor A constructor that takes no arguments is called a default constructor public Pet() { name = No name yet.; age = 0; weight = 0; } Java automatically defines a default constructor if you do not define any constructors

COMP 110: Spring Multiple Constructors You can define multiple constructors All have the same name, but different parameters Group their definitions together

COMP 110: Spring Constructors You cannot call a constructor on an existing object Pet myPet = new Pet(); myPet.Pet("Roberto", 1, 150.0); //error Must use mutators on objects that have already been created myPet.setPet("Roberto", 1, 150.0); //ok

COMP 110: Spring Calling Methods within Constructors Just like calling methods within methods /*constructor*/ public Pet(String initName, int initAge, double initWeight) { setPet(initName, initAge, initWeight); //have the mutator perform the set } /*mutator*/ public void setPet(String newName, int newAge, double newWeight) { name = newName; age = newAge; weight = newWeight; } 19

COMP 110: Spring Programming Demo Grade Distribution A class to display the distribution of letter grades in a class Given the number of A,B,C,D, and Fs, compute the percentage of each type of grade e.g. 15% As, 30% Bs, 30% Cs, 15% Ds, 10% Fs Include accessors and mutators for each type of grade Draw a bar graph of the grade distribution

COMP 110: Spring Programming Demo Output Each * == 2 percent | | | | | | | | | | | ************************************************** **** A ************** B *********C *****D ***F

COMP 110: Spring Friday Recitation No new lab will be posted Get help finishing Program 3 Ask questions about lecture material for midterm