Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Daniel on 4/12/2016.
- */
- //Exercise 2
- import java.awt.*;
- public class Exercise2 {
- public static void main(String[] args){
- DrawingPanel panel = new DrawingPanel(450,150);
- Graphics g = panel.getGraphics();
- drawFigure(g,50,25);
- drawFigure(g,250,45);
- }
- public static void drawFigure(Graphics g, int x, int y){
- Color orange = new Color(255, 141, 0);
- g.setColor(Color.BLACK);
- g.fillOval(x,y,40,40);
- g.fillOval(x+80,y,40,40);
- g.setColor(orange);
- g.fillRect(x+20,y+20,80,80);
- g.setColor(Color.BLACK);
- g.drawLine(x+20,y+20+40,x+20+80,y+20+40);
- }
- }
- //-------------------------------------------------------------------------------------------------------------------------------------
- //Exercise 4
- /**
- * Created by Daniel on 4/12/2016.
- */
- import java.awt.*;
- public class Exercise4 {
- public static void main(String[] args){
- DrawingPanel panel = new DrawingPanel(520,180);
- Graphics g = panel.getGraphics();
- for(int i = 0 ;i<5;i++) {
- Face(g, 10 +i*100, 30);
- }
- }
- public static void Face(Graphics g, int x, int y){
- g.setColor(Color.BLACK);
- g.drawOval(x,y,100,100);
- g.setColor(Color.BLUE);
- g.fillOval(x+20,y+30,20,20);
- g.fillOval(x+60,y+30,20,20);
- g.setColor(Color.RED);
- g.drawLine(x+30,y+70,x+70,y+70);
- }
- }
- //-------------------------------------------------------------------------------------------------------------------------------------
- //Exercise 6
- /**
- * Created by Daniel on 4/12/2016.
- */
- import java.awt.*;
- public class Exercise6 {
- public static final int X = 300;
- public static final int Y = 100;
- public static void main(String[] args){
- DrawingPanel panel = new DrawingPanel(X,Y);
- Graphics g = panel.getGraphics();
- design(g,X,Y);
- }
- public static void design(Graphics g,int x,int y){
- for(int i = 1; i <= 4;i++){
- g.drawRect(x/10*i,y/10*i,x - i*(x/5),y-i*(y/5));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement