New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Computer Science I

by: Reuben Rohan

Computer Science I CMPU 101

Reuben Rohan

GPA 3.88

Marc Smith

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Marc Smith
Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 8 page Class Notes was uploaded by Reuben Rohan on Wednesday October 28, 2015. The Class Notes belongs to CMPU 101 at Vassar College taught by Marc Smith in Fall. Since its upload, it has received 13 views. For similar materials see /class/230535/cmpu-101-vassar-college in ComputerScienence at Vassar College.

Similar to CMPU 101 at

Popular in ComputerScienence


Reviews for Computer Science I


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/28/15
Plan Chapter 3 Chapter 3 Use predefined classes amp objects Using Prede ned Classes amp Objects Chapters 4 and 5 Define new instances of predefined classes CMPU101 ProblemSolving and Abstraction Chapter 6 Marc Smith sect 52 Define new classes Vassar College Spring 2007 Anatomy of Statement to Print to the Screen A Sampling of Prede ned Classes System out println quothelloquot Classes for 0 Reading amp writing Systemout 0 Files amp directories an instance of class Print St ream 0 Graphics amp GUI the receiver println Specific classes with intuitive purposes method applicable to Print St reams 0 Date quothelloquot 0 Time actual parameterargument to println 0 Calendar A First Java Program Filename First java Compile amp run source code in DrJava Compiling produces the file First class If class has a main method run it by typing java First in the Interactions Pane If class has no main method instantiate class and send messages to the object from the Interactions Pane FirstBadjava Program FirstBad class First I void mainstring throws Exceptionl println quothelloquotll public static args System but this code would workjust as well Firstjava Written by Barry Soroka A first Java program class Firs public static void main string args throws Exception System outpr1ntln quothelloquot l Comments are used to separate sections of code and to introduce program author and purpose White space and indentation make your program more readable DrJava Compiling amp Executing 1 Open file First java 2 Compile by clicking on button Compile Allquot gt compiling produces file First class 3 Execute by typing the following in the Interactions Pane java First gt this works since class First has a main method Blankjava A template file Contains the boilerplate skeleton of a program Always compiles Advice Start with code that works compiles and runs Add code for one new feature at a time If there39s a problem then it39s due to the new code Warning The more code you add between compiles the more places you must look to find a problems MemodsfordassPrintstream println parameter String example printin quothelloquot prints its argument amp goes to the next line println parameter none example printin terminates the current line amp goes to the next Imagine an invisible print head capable of moving only left to right on a line or advancing to beginning of next line Blankjava Your name here description of this program lank l Blank i l MemodsfordassPrintstream con nued print parameter String example print quothelloquot prints its argument but doesn39t move to the next line For this method the imaginary print head remains on the same line it was just printing on its position immediately following the last character it printed Signatures amp Overloading signature method name parameter types println String println pri ntln is overloaded because there are two forms differing only in parameters gt it is the name of the method that is overloaded gt two or more methods may share the same name within a class provided they have different signatures Exercise Brainstorm different ways to print out abc using print and println Printing abc Prog0301 ertten by Barry Soroka erte out abc class Prog0301 l Prog0301 l Systemout prlntlnquotabcquot l end class Prog0301 GUI Visible objects Pixel quotpicture elementquot the smallest dot on a computer screen Java s graphics libraries awt amp swing overlap in classes Applet a graphics program which requires a browser Application a standalone graphics program Coordinates o o X This is not the coordinate system we re accustomed to Each color is defined by a triple of numbers specifying intensity of red green and blue RGB Colors Onscreen image is specified by assigning a color to each pixel in the image RGB Red Green Blue color channels a triple Each color channel has an intensity in the range 0255 RGB Color 000 black 255255255 white 16 17 JFrame Color Java sBuilt In Color Name RGB Values black CDIDLBLACK 000 A JFrame is a rectangular graphical object With blue ColorBLUE 0 0255 Width cyan ColorCYAN 0255255 gray ColorGRAY 128 128 128 uppeHeft comer dark gray Color DARKGRAY 54 54 64 lightgmy ColorLIGHTGRAY 192 192 192 C r green ColorGREEN 02550 magma CDIDLMAGENTA 2550255 Java graphics work by placing elements onto JFrames orange ColoLORANGE 955200 that are visible to the user pink ColorPINK 255175175 red ColorRED 25500 Progo302 White ColorWHITE 255255255 yellow ColorYELLoW 2552550 19 MyFrame has a class MyFrame extends JFrame Conta39ner data eld that displays color and quotholdsquot elements public MyFrameO thissetTitlequotOur First JFramequot thissetSize200400 thissetLocation200100 thissetDefaultCloseOperationEXlTONCLOSE Container c thisgetContentPane csetBackgroundColorCYAN end class MyFrame Driver MyFrame f new MyFrame f setVisibletrue Above statements create a new MyFrame object and send it a message to make itself visible MyFrame extends JFrame meaning class MyFrame inherits all the data fields and methods of the JFrame class class MyFrame extends JFrame quotthisquot enables an object to send a public MyFrameo message to itself thissetTitlequotOur First JFramequot thissetSize200400 thissetLocation200100 thissetDefaultCloseOperationEXlTONCLOSE Container c thisgetContentPane csetBackgroundColorCYAN end class MyFrame Prog0303 Geometrical Shapes JFrame frame new JFrame quotRace CarII frame setDefaultC loseOperation JFrame EXIT70N7CLOSE MyPanel mp new MyPanel frame getContentPane addmp frame pack frame setVisibletrue Visible elements are added to JFrame Container One such element is a JPanel class extended by MyPanel an object that provides a surface for drawing painting or displaying images public MyPanelO thissetBackgroundColorWHITE thissetPreferredSizenew Dimension700450 III public void paintComponent Graphics page superpaintComponentpage pagedrawRect100150500150 pagefillOval150250100100 pagefillOval450250100100 Prog0304 Display a JPEG Image class MyPanel extends JPanel n I public MyPanelO thissetBackgroundColorWHITE thissetPreferredSizenew Dimension400300 II n Common geometric objects populate the JPanel drawRectxywidthheight fillRectxywidthheight fillOvalxywidthheight oval bounding box drawOvalxywidthheight setColorColorRED drawLinexlylx2y2 public void paintComponent Graphics page superpaintComponentpage Image image new lmagelconquotbaconjpgquotgetlmage pagedrawlmageimage5050this III end class MyPanel ProgO305 Diagonals class MyPaneI extends JPaneI public void paintComponent Graphics page superpaintComponentpage int width getV dth int height getHeightO pagesetCoIorCoorYELLOV pagedrawLine00widthheight pagedrawLineOheightwidth0


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.