slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
import java.awt.Color ; import javax.swing.JFrame ; public class Target { PowerPoint Presentation
Download Presentation
import java.awt.Color ; import javax.swing.JFrame ; public class Target {

Loading in 2 Seconds...

play fullscreen
1 / 7

import java.awt.Color ; import javax.swing.JFrame ; public class Target { - PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on

Supplier Class. import java.awt.Color ; import javax.swing.JFrame ; public class Target { private Oval outerWhiteOval , redOval , innerWhiteOval , blueOval ; public Target( int x, int y, int s) { int eighthS = ( int )(s / 8.0); outerWhiteOval = new Oval(x, y, s, s);

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 'import java.awt.Color ; import javax.swing.JFrame ; public class Target {' - baina


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
slide2

Supplier Class

import java.awt.Color;

import javax.swing.JFrame;

public class Target {

private Oval outerWhiteOval, redOval, innerWhiteOval, blueOval;

public Target(int x, int y, int s) {

inteighthS = (int)(s / 8.0);

outerWhiteOval = new Oval(x, y, s, s);

outerWhiteOval.setBackground(Color.white);

redOval = new Oval(eighthS, eighthS, 6*eighthS, 6*eighthS);

redOval.setBackground(Color.red);

outerWhiteOval.add(redOval);

innerWhiteOval = new Oval(eighthS, eighthS, 4*eighthS, 4*eighthS);

innerWhiteOval.setBackground(Color.white);

redOval.add(innerWhiteOval);

blueOval = new Oval(eighthS, eighthS, 2*eighthS, 2*eighthS);

blueOval.setBackground(Color.blue);

innerWhiteOval.add(blueOval);

}

public void addTargetTo(JFramejf) {

jf.add(outerWhiteOval);

}

}

slide3

Client Class

import java.awt.Color;

import javax.swing.JFrame;

public class Driver {

private JFrame win;

private Target leftTarget, rightTarget, bigTarget;

public Driver() {

win = new JFrame("Targets");

win.setBounds(20, 20, 600, 500);

win.getContentPane().setBackground(Color.black);

win.setLayout(null);

win.setVisible(true);

leftTarget = new Target(10, 10, 100);

leftTarget.addTargetTo(win);

rightTarget = new Target(490, 10, 100);

rightTarget.addTargetTo(win);

bigTarget = new Target(200, 250, 200);

bigTarget.addTargetTo(win);

win.repaint();

}

public static void main(String[] args) {

new Driver();

}

}

slide6

Another Supplier Class

public class Fraction {

private int numerator;

private int denominator;

public Fraction(int n, int d) {

numerator = n;

denominator = d;

simplify();

}

public intgetNumerator() {

return numerator;

public intgetDenominator() {

return denominator;

}

public void add(Fraction f) {

}

public void multiply(Fraction f) {

numerator = numerator*f.getNumerator();

denominator = denominator*f.getDenominator();

simplify();

}

private void simplify() {

}

}