1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
frequently used static methods
floor(x) //returns a double; rounds x down
ceil(x) //returns a double; rounds x up
pow(x,y) //returns ?? x to the power y
abs(x) //returns ?? the absolute value of x?
sqrt(x) //??
round(x) //returns an int; ???
min(x,y) //???
max(x,y) //???
random() //returns double >????
use a ceiling return method
Scanner keyboard = newScanner??????
how are all Math functions static?
they are called directly with their class name, Math
???
System.out.printf()
formatted printing
2 parameters; how to format and what to format?
double dec and its output
System.out.printf(?????)
Math.random();
generates a random double from 0.0 up to but not including 1.0; random number in the range of [0.0, 1.0)
can cast as other things, like ints, ex: (int)(Math.random()*2 + 10) ints[10,12) //10 or 11 are the only possibilities //can’t just round using floor or ceil because that would still cast it as a double, would be __.0, even using round itself wouldn’t give equally likely outcomes -0 and 9 would be less likely
range of these
Math.random()
Math.random()*2
Math.random()*5 + 1
Math.random()*4 - 2
Math.random()*__ + __
??
??
??
??
Math.random()*range + minimum [0.0*rnage +min, ????]
how to generate a dice roll
??
where do you start for graphics? how do x and y go? give some examples
at the top left corner
x goes across
y goes down
window.fillOval(x, y, width, height); //?
window.fillRect(int x, int y, int width, int length);
parameter/argument
a channel used to pass information to a method.
//ex: setColor() is a method of the Graphics class that receives a Color
frequently used graphics methods
drawLine(a,b,c,d) //draws line starting at alb and going to c,d
drawRect(x,y,w,h) //????
fillRect(x,y,w,h) //????
setColor(x) //??
drawString(s,x,y) //??
drawOval(x,y,w,h) //??
fillOval(x,y,w,h) //??
drawArc(x,y,w,h,startAngle,arcAngle) //draws an arc at spot x,y that is w wide and h tall //startAngle specifies the start of the arc, arcAngle specifies the length of the arc?
fillArc(x,y,w,h,startAngle,arcAngle) //draws a filled arc at spot x,y rho is w wide and h tall //startAngle specifies the start of the arc, arcAngle specifies the length of the arc?
Rectangles in graphics (examples)
window.setColor(Color.BLUE);
window.fillRect(100,100,100,20);
window.setColor(Color.GRAY);
window.drawRect //????
????
Circles in graphics (examples)
window.setColor(Color.BLUE);
window.drawOval(100,50,40,40);
window.setColor(Color.GREEN);
???
???
arcs in graphics (examples)
window.setColor(Color.BLUE);
window.drawArc(100,100,40,40,90,90);
window.setColor(Color.GREEN);
window.drawArc(100,175,???)
???
???
Graphics Runner
public class GraphicsRunner extends JFrame
{
//variables not shown
public GraphicsRunner
????