you should understand everything on this slide
Download
Skip this Video
Download Presentation
You should understand everything on this slide

Loading in 2 Seconds...

play fullscreen
1 / 13

You should understand everything on this slide - PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on

You should understand everything on this slide. public class TestClass { public static void main(String[] args ) { System. out .println ( "public static void main(String[] args ) is where it all begins!" ); int myIntegerVariable = 77;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' You should understand everything on this slide' - selma


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
you should understand everything on this slide
You should understand everything on this slide

publicclassTestClass {

publicstaticvoid main(String[] args) {

System.out.println("public static void main(String[] args) is where it all begins!");

intmyIntegerVariable = 77;

System.out.println("I can have cool integer variables like "

+ myIntegerVariable);

TestClassmyObject = newTestClass();

// I can also call functions like this

myObject.myFunction("Test");

// ...but I haven\'t fully explained yet what the deal with "new" is

// and how myObject is involved.

}

publicvoidmyFunction(String foo) {

int[] arrayVariable = newint[25];

for(int i = 0; i < arrayVariable.length; i++) {

System.out.println("Array Value at index " + i + " is " + arrayVariable[i]);

}

}

}

classes and objects arraylists hashmaps hashsets

Classes and ObjectsArrayListsHashMapsHashSets

When arrays are just not cool enough.

in case you missed the email
In case you missed the email…
  • The Link is now staffed 5pm-11pm, Sunday-Thursday! Get help!
  • You first APT assignment is due tomorrow at 8am. How many folks are planning to be at the Link tonight?
  • Hangman (due next Wednesday 1/25 at 8am) is posted and ready to go. Many other things are coming due too!
  • Videos and notes will be linked off the syllabus
in the optional textbook
In the Optional Textbook
  • Read chapters 1-3 (should be fast, but do some of the exercises at the end of Chapter 3)
  • The later part of this class will also deal with bits of chapter 16
the story thus far
The Story Thus Far

publicclassTestClass {

publicstaticvoid main(String[] args) {

System.out.println("public static void main(String[] args) is where it all begins!");

intmyIntegerVariable = 77;

System.out.println("I can have cool integer variables like "

+ myIntegerVariable);

TestClassmyObject = newTestClass();

// I can also call functions like this

myObject.myFunction("Test");

// ...but I haven\'t fully explained yet what the deal with "new" is

// and how myObject is involved.

}

publicvoidmyFunction(String foo) {

int[] arrayVariable = newint[25];

for(int i = 0; i < arrayVariable.length; i++) {

System.out.println("Array Value at index " + i + " is " + arrayVariable[i]);

}

}

}

objects they combine data and functions together
Objects: they combine data and functions together

Data: “cgga”

Functions:

setStrandData

getStrandData

mutate

addBasePair

Data: “gattac”

Functions:

setStrandData

getStrandData

mutate

addBasePair

addbasepair function
addBasePair function

DnaStrand strand = new DnaStrand();

strand.setStrandData(“cga”);

//prints cga

System.out.println(strand.getStrandData());

strand.addBasePair(“t”);

//prints cgat

System.out.println(strand.getStrandData());

why objects
Why Objects?
  • See the coolness of java’s String class!
beware
BEWARE!

Never compare 2 strings like this:

String foo;

String bar;

//some other code

if(foo == bar) {

System.out.println(“Strings are equal!”)

}

Always compare them like this:

if(foo.equals(bar)) {

System.out.println(“Strings are equal!”)

}

is3rdbasepaircytosine
is3rdBasePairCytosine

DnaStrand strand = new DnaStrand();

strand.setStrandData(“tac”);

if(strand.is3rdBasePairCytosine());

{

System.out.println(“cytosine!”);

}

The function is3rdBasePairCytosine returns a boolean – a primitive type that is either true or false

You might check out the String Javadoc for some useful functions

4 classes you will get to know is compsci 100
4 Classes You Will Get to Know is CompSci 100
  • String
  • ArrayList – an expandable list you can add or remove elements from
  • HashSet – a list that prevents duplicate elements
  • HashMap – a “dictionary” where you can associate a particular key with a particular value
getbasecounts
getBaseCounts

public HashMap<Character,Integer> getBaseCounts()

{

HashMap<Character,Integer> baseCounts = new

HashMap<Character,Integer>();

baseCounts.put(‘c’, 0);

baseCounts.put(‘g’, 0);

baseCounts.put(‘a’, 0);

baseCounts.put(‘t’, 0);

for(inti = 0; i < myData.length(); i++) {

char currentBase = myData.charAt(i);

//your code goes here

}

return baseCounts;

}

When you’re finished, submit your code via ambient.

what you should know
What you should know
  • What the difference between class and objects is, and how objects work
  • 4 key java objects to help you with apts and homeworks:
    • String
    • ArrayList
    • HashMap
    • HashSet
ad