Review Sheet for Introduction to Programming in Java | CSIS 110, Study notes of Javascript programming

Material Type: Notes; Professor: Hanks; Class: Intro to Programming in Java; Subject: Computer Science Info Systems; University: Fort Lewis College; Term: Winter 2007;

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-3jl-1
koofers-user-3jl-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 – Lecture 7
Quiz: Wednesday. Material in Chapters 1 and 2.
Read: Chapter 3, section 3.1 to 3.11.
Partner assignment sheets
Quiz Review – Go over review questions that I handed out last time.
Last Time
We looked at the NumberDisplay class:
- Abstraction and modularization
- boolean operations: &&, ||, and !
Review boolean operations. Give some example boolean expressions and ask students to
evaluate.
So, what would happen if we replaced the && operator with || in the setValue
method?
The accessor method getDisplayValue
This method also gets the value, but as a String instead of an int. What is it doing?
if ( value < 10 )
return “0” + value;
else
return “” + value;
What’s going on here?
- What does the expression “0” + value do?
- What does the expression “” + value do?
- Statements after return statement?
- What’s the purpose of this if statement?
Does this method work correctly in all cases? Does it make any assumptions? What if the
value of limit is 500?
The increment method
The increment method adds 1 to the value, but has to reset it to 0 if the limit is reached.
This method uses the modulo operator:
value = ( value + 1 ) % limit;
pf3

Partial preview of the text

Download Review Sheet for Introduction to Programming in Java | CSIS 110 and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 – Lecture 7

Quiz: Wednesday. Material in Chapters 1 and 2. Read: Chapter 3, section 3.1 to 3.11. Partner assignment sheets Quiz Review – Go over review questions that I handed out last time. Last Time We looked at the NumberDisplay class:

  • Abstraction and modularization
  • boolean operations: &&, ||, and! Review boolean operations. Give some example boolean expressions and ask students to evaluate. So, what would happen if we replaced the && operator with || in the setValue method? The accessor method getDisplayValue This method also gets the value, but as a String instead of an int. What is it doing? if ( value < 10 ) return “0” + value; else return “” + value; What’s going on here?
  • What does the expression “0” + value do?
  • What does the expression “” + value do?
  • Statements after return statement?
  • What’s the purpose of this if statement? Does this method work correctly in all cases? Does it make any assumptions? What if the value of limit is 500? The increment method The increment method adds 1 to the value, but has to reset it to 0 if the limit is reached. This method uses the modulo operator: value = ( value + 1 ) % limit;

The % operator calculates the remainder of integer division. [Give an example – divide 53 by 4 using longhand]. Then ask what is the remainder of 17 / 4. What is the value of these expressions? 5 % 2 10 % 3 4 % 7 5 % 5 What possible values could this expression produce: x % 5? So, what is the above statement doing?