CE00371-1 INTRODUCTION TO SOFTWARE DEVELOPMENT


Lab/Tutorial 4

Assessment weight : 3%

Due : Week 6

Part A Programming exercises.

  1. Write a Java Applet to display your name, and student number

  2. Use MS Notepad or some other simple text editor to create a web page that will look similar to this image, and save in a file named "Lab4Question1.html". Do not use an HTML authoring tool or Microsoft Word to do this exercise. You should use appletviewer to check your works in question 1, capture the screen using MS Paint/other graphic tools ,and use a table to display your answer. As the final step, add a link for Lab4Question1.html to your Web page that you created in Lab1.

  3. Based on the program MaximumTest and the program which you have written for Question 6 of Lab3, modify your program to make use of the following methods:

    public double maximum( double x, double y, double z )

    public double minimum( double x, double y, double z )

    which take three numbers in the parameter list and return the maximum and minimum respectively.

  4. Given the following ChinaFlag Applet

    import java.awt.*;
    import java.applet.Applet;
    public class ChinaFlag extends Applet {
      public void paint( Graphics g ) {
        
        int[] xArr =  {43,78,85,96,130,102,113,88,61,70};
        int[] yArr =  {75,75,44,75,75,100,128,109,128,100};
    
        int[] x1Arr =  {168,176,180,181,189,180,180,175,168,171};
        int[] y1Arr =  {40,42,36,44,47,50,59,52,53,47};
    
        int[] x2Arr =  {194,202,208,206,213,204,202,199,191,196};
        int[] y2Arr =  {86,89,85,93,98,99,105,99,98,94};
    
        int[] x3Arr =  {182,188,192,195,204,196,198,193,186,188};
        int[] y3Arr =  {138,138,130,138,138,145,152,148,153,145}; 
    
        int[] x4Arr =  {143,151,156,157,165,155,157,152,144,148};
        int[] y4Arr =  {178,181,174,182,185,188,197,191,193,186};
    
        g.setColor(Color.green);
        g.fillRect(10, 15, 480, 335);
    
        g.setColor(Color.red);
        g.fillRect(15, 20, 467, 322);
    
        g.setColor(Color.yellow);
        g.fillPolygon(xArr,yArr,10);
        g.fillPolygon(x1Arr,y1Arr,10);
        g.fillPolygon(x2Arr,y2Arr,10);
        g.fillPolygon(x3Arr,y3Arr,10);
        g.fillPolygon(x4Arr,y4Arr,10);
      }
    }
    

    Write an applet to read three number r, g, and b and create a new color using constructor method Color(int r,int g,int b) of Color class. Paint the flag using the new color as background color.

  5. Publish your answers after you finished.