Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

Draw a house or choice of your own, including two shapes and lines.
1. Work on your house: add different color in all and add spider webs at two house corners, fence, grasses, clouds, sun rays ... (use loops).

Notes:
web -
a web in the upper-right corner of the N x N image:
for(int k = 0; k <= 50; k++){
g.drawLine(N * k / 50, 0, N, N * k / 50);
}
sunshine rays:
x1 = (int)(x0 + size * Math.cos(angle * Math.PI / 180));
y1 = (int)(y0 + size * Math.sin(angle * Math.PI / 180));

Templates:

1)

public class DrawPanel extends JPanel {
   public void paintComponent( Graphics g )
   {
       super.paintComponent(g);
      
       int width = getWidth();
       int height = getHeight();        
  
       // 1. draw a line between A (1, 2) and B (50,100)
      
      
       // 2. draw a line parallel to the first line AB  
      
      
       // 3. write "Hello world" starting at position of (100,100)
      
      
       // 4. draw a red circle at any position

   }
}

2)

import java.awt.Graphics;
import javax.swing.JPanel;
import javax.swing.JFrame;


public class DrawPanelTest {
   public static void main( String[] a )
   {
       DrawPanel panel = new DrawPanel();
       JFrame app = new JFrame();
      
       app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       app.add(panel);
       app.setSize(300,400);
       app.setVisible(true);
   }
}

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.