



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




































February 10, 2009 CMPSCI 121, Spring 2009 Introduction to Problem Solving with Computers Prof. Learned-Miller
Instructor: Andrew Chan Two Sessions per week Wednesdays: 6:45-8:00 PM Sundays: 8:45-10:00 PM Location: Library, room 1049
Instructions under “resources” http://bb-edlab.cs.umass.edu/cs121_S09/ Off-campus access: Username: cs Password: elM121cs Get an account:
If you're using a class (like Infant), the code for that class should be in the current directory.
int x; String name; Infant emmaLM; // an object!!! Types int String double Infant char EriksFancyTaxForm
int x = 3; String name = “Erik”; Infant emmaLM = new Infant(“Emma”,0);
Creating objects with new command Attributes Methods Calling methods with values Calling methods without values
12 Designing a container Making an instance Storing info Retrieving stuff Storing stuff Using the instance Using the instance Declaring an instance Specifying a class Retrieving info Other methods A new class of briefcases Change infant age Store Infant age Make an instance: myKid Define “Infant” Class Fill briefcase with stuff Create one briefcase And take stuff out
new Infant(“Lizzie”,4); new Infant("baby", 7); new Infant(3,"bobbie"); // error new Infant("Lizzie"); // error
Infant lizzie = new Infant(“Lizzie”,4); Infant baby = new Infant("baby", 7); Infant bobbie = new Infant(3,"bobbie"); // error Infant lizzie = new Infant("Lizzie"); // error
Car hotrod = new Car("Chevy",10,5);
Create some objects
Data stored in your object: Name Age make of car Picture of a person Other objects Anything at all you want to store about an object!!!