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


by: Jonas Bartell


Marketplace > University of Pittsburgh > ComputerScienence > CS0007 > INTROTOCOMPUTERPROGRAMMING
Jonas Bartell
GPA 3.77


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

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 27 page Class Notes was uploaded by Jonas Bartell on Monday October 26, 2015. The Class Notes belongs to CS0007 at University of Pittsburgh taught by Staff in Fall. Since its upload, it has received 37 views. For similar materials see /class/229389/cs0007-university-of-pittsburgh in ComputerScienence at University of Pittsburgh.

Similar to CS0007 at Pitt

Popular in ComputerScienence




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/26/15
string equalities String abc quotabcquot String def quotdefquot Bad way if abc def quotabcdefquot Good way if abc defequals abcdef httpjavasuncomjZSel3docsapijavalangStringhtml google quotjava stringquot infinite X1 y1 while Xlt5 Xy whileylt3 Xy void functions void functionName do something function with return value lg addNumbersint x int y int ZXy return 2 function with return value boolean compareNumbersint x int y ifXlty return true else return false public static void mainString args 6ystemoutprintlnquotHow many points did you getquot a ConsoleinreadInt SystemoutprintlnquotYour grade is quot letterGradea char letterGradeint numGrade if numGrade gt 90 return 39A39 90 or above gets an A else if numGrade gt 80 return 39839 80 to 89 gets a B else if numGrade gt 65 return 39C39 65 to 79 gets a C else if numGrade gt 50 return 39D39 50 to 64 gets a D else return 39F39 anything else gets an F subsan ques on ssubstringi j returns firstj characters of s starting at index i first j1 characters of s starting at index i s starting at index i and ending atj s starting at index i and ending at j1 olqgut and alasst and strings What39s the difference between and equals How can I check whether a string s is the empty string Is there a difference between the empty string and null if the following legal strimtoLowerCaseequalsquotsaturdayquot cigar and QMKSSQS and strings data types primitive types vs reference types primitive types in Java boolean char byte short int long float and double arrays are object call by value thl meoemhg anan let k be the smallest such index then the string whose character at position k has the smaller value as determined by using the lt operator lexicographically precedes the other string thischarAtkanotherStringcharAtk if there no such index thislength anotherStringlength returns integer Chap 7 Inheritance child ch d grandchild I grandchild I grandchild I grandchild 1 An example from javalang Number String Long 1 Integer Double 3 Dynamic Method Dispatch SuperClassjava a a sample super class class Superclass public veid prlnt Systemoutprlntln quot inside Superclassquot SubClassjava a a subclass of Superclass class Subclass extends Superclass public veid prlnt Systemoutprlntln quot inside Subclassquot TestInherltjava e overrldden method selection class TestInherlt public static void mainstring args Superclass s new Superclass sprlnt s new Subclass sprlnt PredatorPrey An abstract class A simple simulation of an arti cial ecology 3 I lelngjava a the superclass for all llfe forms abstract class lelng abstract Count getCOunt 39 abstract lelng nextWorld world abstract char toChar character for thls form vold computeNelghborsWorld world world clearNelghborCounts lnt r a 7 al world cells row column getCount setal for lnt 3 l lt l l for 71 j lt 1 3H world cells rowl columnj getCount lnc lnt row column locatlon class Fox extends lelng Foxlnt r int c int a r column a c age lelng nextWorld world computeNelghborsworldL 1f 5 FoxnelghborCountget gt 5 too many Foxes return new Emptyrow column else if age gt LIFEiEXPECTANCY return new Emptyrow else if FOX ls too old column RabbltnelghborCountget return new Emptyrow else column starved return new Foxrow column age 1 public String tostrlng return quotFox age quot char tochar return 39F39 Count getCount age return nelghborCount l static Count nelghborCount new Count private int age prrvate flnal r a nt LIFEiEXPECTANCY 5 Why must getCount and neighborCount be repeated in each subclass of Living Why not just move these de nitions to Living Answer There is no way to WIite a method in Living that accesses a static eld in the subclasses of Living We need a neighborCount for each of Fox Rabbit Grass and Empty ciass Rabbit extends LiVing Rabbitint r int c int a row r column c age 5 Count getCount return neighborCount static Count neighborCount new Count private int age private final int LIFEiEXPECTANCY 3 Warm up questions What is the most appropriate data type to represent the following quantities a Your grade point average b How many students go to Pitt c Your middle initial d A city name 9 1T Random value Mathrandom Random value Mathrandom100 Random value intMathrandom100 Random value intMathrandom1001 Average program switch case analysis public class SwitchDemo public static void mainString args int month 8 switch month case 1 case 239 case 3 case 4 case 5 case 6 case 7 case 8 case 9 case case case default System System System System System System System System System System System System System out out out out out out printlnquotJanuaryquot break printlnquotFebruaryquot break out printlnquotMarchquot break printlnquotAprilquot break out printlnquotJunequot break out out out printlnquotOctoberquot break printlnquotNovemberquot break out out printlnquotMayquot break printlnquotJulyquot break printlnquotAugustquot break printlnquotSeptemberquot break printlnquotDecemberquot break printlnquotNot a monthquot break import tio class Test int input Consoleinreadnt int output 1 switchinput case 2 output 3 break case 3 output 4 case 4 output input 5 case 5 output output 1 break default Systemoutprintn nput unknownquot Systemoutprintn The output is quot output public class SwitchDem02 public static void mainString args int month 2 int year 2000 int numDays 0 3 5 7 8 case 10 case 12 numDays 31 break case 4 case 6 case 9 case 11 numDays 30 break case 2 if year 4 ampamp year 100 year 400 numDays 29 else numDays 28 break default numDays 0 break Systemoutprint1nquotNumber of Days quot numDays


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!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"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.