Setter / Mutator methods Methods which accept information and set the value of an object’s property, are called either –setter methods (because they set.

Slides:



Advertisements
Similar presentations
We Can Read About Mixing Colors
Advertisements

1 CSCE 1030 Computer Science 1 Introduction to Object Oriented Programming.
Copyright © Texas Education Agency, Computer Programming Class Basics.
CSS Link Styling. The Anchor Element: Link text between the opening and closing can be styled using CSS. Some of the properties that can be set are: font-family,
Help Session How To Get Started Design Parameters
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
 Setter methods ◦ public methods that set the value of instance variables to a value specified by the call to the argument ◦ Setter methods do not violate.
Object Oriented Programming.  OOP Basic Principles  C++ Classes  September 2004  John Edgar 22.
Color (1) Turtle class contains a method to change the pen color Note: before using Color class, you should add following line in the top of the source.
All About Colors!!! All About Colors!!!!! Caitlyn Evershed
More C++ Bryce Boe 2013/07/18 CS24, Summer 2013 C.
UML Basics & Access Modifier
PARAMETERS Making Messages Specific Setting Up Associations Actual and Formal Parameters Return Types Accessor and Mutator Methods.
The Color Wheel Claire Heider The Primary Colors.
Colour Theory. The Colour Wheel The colour wheel is a basic tool we use when working with colours.
For Wednesday No new reading Complete WebCT quiz.
Functions, Objects, and Programming IDIA 619 Spring 2014 Bridget M. Blodgett.
Local Variables Garbage collection. © 2006 Pearson EducationParameters2 of 10 Using Accessors and Mutators Together What if you want to get a property.
Object-Oriented Design Justin Callanan CS 597. Object-Oriented Basics ● Data is stored and processed in “objects” ● Objects represent generalized real.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
OBJECTIVE 39: STUDENTS WILL DEMONSTRATE UNDERSTANDING BY DESCRIBING IMPRESSIONISM ART CHARACTERISTICS.
Lauren Wessel September 17, 2008 Lauren Wessel September 16, 2008.
By: Elizabeth Hayden Mrs. Valle Art Class.  I learned a great song that showed and taught me the primary and secondary colors.  I learned how the primary.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
OOP with Objective-C Categories, Protocols and Declared Properties.
Colors of Pigment The primary colors of pigment are magenta, cyan, and yellow. [
Section 6.1 CS 106 Victor Norman IQ Unknown. The Big Q What do we get by being able to define a class?! Or Do we really need this?!
FRACTIONS & SHAPES BY:. How many of these are colored red? * out of *.
Mixing Complementary Colors to create neutrals. Complementary colors are directly across from one another on the color wheel. When mixed they get various.
Art Class for 1 st Grade with Ms. Jenzano Click the Paint Brush to Move on.
Color Theory Primary Colors Quiz Secondary Colors.
An urn contains 1 green, 2 red, and 3 blue marbles. Draw two without replacement. 1/6 2/6 3/6 2/5 3/5 1/5 3/5 1/5 2/5 2/30 3/30 2/30 6/30 3/30 6/30.
Scientific Notation. = 5.4 =3.47 Write the following in standard form A 1.8 X 10⁴ B 3.47 X 10⁷ C 4.3 X 10⁰ D 5.4 X 10⁻⁴ E 5 X 10⁻⁶ F (6 X 10⁴) (7 X 10⁵)
 the relationship between colors  Primary Colors: colors that cant be made by mixing other colors (red, yellow, blue)  Secondary Colors: Colors made.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Re-Intro to Object Oriented Programming
Sorting and Grouping.
Color.
ART HISTORY QUIZ #1 FRIDAY, NOVEMBER 6th.
Creating Your OwnClasses
Butterfly Maths Each caterpillar must be coloured the correct pattern for it to turn into a butterfly. Work out each problem to know how to colour each.
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
Colors.
The Color Wheel By Denise Jackson.
Name: _______________________________
مقالات إدارية حبيبات القهوة!!!! مبيعات قطاع الأعمال - الأحساء
Average Number of Photons
Image Processing Results
C++ Interlude 1 C++ Classes
CSE 113 A January 26 – 30, 2009.
CS 302 Week 9 Jim Williams.
Can I color yellow?. Can I color yellow?
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
For the data set classify_regress.dat, find w.
Python Practice !!!.
What Color is it?.
January 26 – 30, 2009 CSE 113 B.
numbers letters colors shapes animals 1pt 1 pt 1 pt 1pt 1 pt 2 pt 2 pt
Announcements Lab 5 was due today Program 3 due Monday by 12pm
CER Technique
Color Theory.
Help Gina and Tina color the numbers
The Colors of Our World Mary Kate DeLary.
Classes and Objects CGS3416 Spring 2019.
Color Box Button - Gray Type : object Type : object Type : object
Let’s Learn the Basic Colors
Presentation transcript:

Setter / Mutator methods Methods which accept information and set the value of an object’s property, are called either –setter methods (because they set the value of a property) –mutator methods (because they change – mutate – the value of a property) These methods typically have names that start with “set” 1

setColor Both the Ant and the Caterpillar have setColor methods. By calling their setColor methods we can change the color of our Ant and Caterpillar objects. The setColor method requires that a reference to a java.awt.Color object be provided as an argument in the method call. 2

java.awt.Color class Instances of the java.awt.Color class represent colors. A color is described by how much of each of the three colors red, green and blue are mixed together. There are some predefined color objects in the java.awt.Color class, such as: java.awt.Color.RED java.awt.Color.BLUE 3

Example Suppose a is an Ant, and c is a Caterpillar. Then the following method call sets the color of the Ant object to red: a.setColor(java.awt.Color.RED) Likewise, the following method call sets the color of the Caterpillar object to blue: c.setColor(java.awt.Color.BLUE) 4

Getter / Accessor methods Methods which return information, the value of an object’s property, are called either –getter methods (because they get the value of a property) –accessor methods (because they permit access to the value of a property) These methods typically have names that start with “get” 5

getColor Both the Ant and the Caterpillar have getColor methods. By calling their getColor methods we can find out the color of our Ant and Caterpillar objects. The getColor method requires no argument in the method call. 6

Example Supposing again that a is an Ant. Then the following method call gets a reference to the color of the Ant object: a.getColor() Likewise, the following method call sets the color of the Caterpillar object to blue: c.setColor(java.awt.Color.BLUE) 7

Making c and a have the same color c.setColor(a.getColor()) Swapping colors with two variables: java.awt.Color colorOne = a.getColor(); java.awt.Color colorTwo = c.getColor(); c.setColor(colorOne); a.setColor(colorTwo); Exercise: swapping colors with just one variable. 8