creating objects n.
Download
Skip this Video
Download Presentation
Creating Objects

Loading in 2 Seconds...

play fullscreen
1 / 5

Creating Objects - PowerPoint PPT Presentation


  • 92 Views
  • Uploaded on

Creating Objects. Pepper. Objects You Already Create. Scanner: Import java.util.Scanner ; Scanner scn = new Scanner(System.in); Pictures: import javalib.worldimages .*; import java.awt.Color ; WorldImage myCircle = AImage.makeCircle (50,Color.blue, Mode.filled );

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 'Creating Objects' - rose-hudson


Download Now 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
objects you already create
Objects You Already Create
  • Scanner:
    • Import java.util.Scanner;
    • Scanner scn = new Scanner(System.in);
  • Pictures:
    • import javalib.worldimages.*;
    • import java.awt.Color;
    • WorldImagemyCircle = AImage.makeCircle(50,Color.blue, Mode.filled);
    • Color bluegrey = new Color(23,32,43);
new object decimalformat
New Object - DecimalFormat
  • Knows how to format a decimal number
  • Library: java.text.DecimalFormat
    • Import java.text.DecimalFormat;
  • Tell it your format method when you create it
    • DecimalFormatmyf = new DecimalFormat("0.0#");
  • Ask your formatter to format any number
    • myf.format(3.555);
    • myf.format(x);
  • Many formats:

http://pic.dhe.ibm.com/infocenter/adiehelp/v5r1m1/index.jsp?topic=%2Fcom.sun.api.doc%2Fjava%2Ftext%2FDecimalFormat.html

new object random
New Object - Random
  • Knows how to create a random number
  • Library: java.util.Random
    • import java.util.Random
  • Create a random maker guy
    • Random r = new Random();
  • Ask him to give you a number out of # choices:
    • nextInt(6); returns 0 – 5
    • nextInt(13); returns 0-12
exercise
Exercise
  • Generate 2 dice values using Random
  • Print the two dice values
  • Divide by 2 to get the average
  • Print the average with only 1 decimal place