Homework Solution: You are to write a program using Java graphics to display nautical signal flags. There are 26 letter signal flags. Each flag is 150 by 150 pixels. You only have to i…

    COMP163 Nautical Flags Program You are to write a program using Java graphics to display nautical signal flags. NAUTICAL FLAG ALPHABET W XYZ There are 26 letter signal flags. Each flag is 150 by 150 pixels. You only have to implement the six letters I, J, K, P, U and X. The remaining letters have been implemented by your instructor. Your program eebec3bbe79ec714b43ca9c9f3f31b98.png
    You are to write a program using Java graphics to display nautical signal flags. There are 26 letter signal flags. Each flag is 150 by 150 pixels. You only have to implement the six letters I, J, K, P, U and X. The remaining letters have been implemented by your instructor. Your program. must extend the abstract class NauticalFlags. public class MyFlags extends NauticalFlags { public static void main(String[] unused) { MyFlags prog = new MyFlags (): //create object of your program"s class } public void letterl(java.awt.Graphics page) { // call Graphics methods to draw the flag for the letter D } public void letterJ(java.awt.Graphics page) { // call Graphics methods to draw the flag for the letter E } // similarly for the letters K. P. U and X. The methods must have the correct name } You will need to download the NauticalFlags.jar file and save it some place where you can find it, such as your MyDocuments directory. In jGRASP, click on: Settings then PATH/CLASSPATH then Workspace then tab Class then tab Classpaths Click the New button and browse to the directory containing the jar file and select NauticalFlags.jar Press OK

    Expert Answer

     
    The following is the required program as per your requirements.

    COMP163 Naval Faints Program You are to transcribe a program using Java graphics to vault naval eminent faints. NAUTICAL FLAG ALPHABET W XYZ There are 26 epistle eminent faints. Each faint is 150 by 150 pixels. You merely enjoy to instrument the six epistles I, J, K, P, U and X. The fostering epistles enjoy been instrumented by your schoolmaster. Your program
    eebec3bbe79ec714b43ca9c9f3f31b98.png

    You are to transcribe a program using Java graphics to vault naval eminent faints. There are 26 epistle eminent faints. Each faint is 150 by 150 pixels. You merely enjoy to instrument the six epistles I, J, K, P, U and X. The fostering epistles enjoy been instrumented by your schoolmaster. Your program. must enlarge the unembodied arrange NavalFlags. open arrange MyFlags enlarges NavalFlags { open static wanting deep(String[] unused) { MyFlags prog = upstart MyFlags (): //invent sight of your program”s arrange } open wanting epistlel(java.awt.Graphics page) { // allure Graphics systems to induce the faint restraint the epistle D } open wanting epistleJ(java.awt.Graphics page) { // allure Graphics systems to induce the faint restraint the epistle E } // similarly restraint the epistles K. P. U and X. The systems must enjoy the amintent call } You obtain deficiency to download the NavalFlags.interfere refine and economize it some fix where you can furnish it, such as your MyDocuments directory. In jGRASP, click on: Firmtings then PATH/CLASSPATH then Workspace then tab Arrange then tab Arrangepaths Click the Upstart rush and browse to the directory containing the interfere refine and choice NavalFlags.interfere Press OK

    Expert Rejoinder

     

    The subjoined is the required program as per your requirements.

    Supplement the outer interfere refine NavalFlags.interfere in your scheme and work the regulation.

    Regulation to observation is ardent at the intent. Get end to me if you enjoy any doubts.

    Program Screenshot:

    Sample Output screenshots:

    Regulation to observation:

    import java.awt.Color;

    import java.awt.Graphics;

    // fix the arrange

    open arrange MyFlags enlarges NavalFlags {

    // approve the variables.

    private static int WIDTH_Of_PAGE= 150;

    private static int HEIGHT_OF_PAGE = 150;

    // fix the deep() system

    open static wanting deep(String[] args) {

    // invent an sight restraint the arrange

    MyFlags prog = upstart MyFlags();

    }

    // specification of the system epistleI(Graphics page)

    open wanting epistleI(Graphics page) {

    // firm the hue and appoint the rectangle

    page.setColor(Color.YELLOW);

    page.fillRect(0, 0, WIDTH_Of_PAGE, HEIGHT_OF_PAGE);

    // compute the character point

    int characterx = WIDTH_Of_PAGE /2;

    int charactery = HEIGHT_OF_PAGE /2;

    // compute the radius

    int radius = WIDTH_Of_PAGE /4;

    // compute the x and y coordinates.

    int x = characterx – radius;

    int y = charactery – radius;

    // firm the hue and appoint the Oval

    page.setColor(Color.BLACK);

    page.fillOval(x, y, 2*radius, 2*radius);

    }

    // specification of the system epistlej(Graphics page)

    open wanting epistleJ(Graphics page) {

    int Top = HEIGHT_OF_PAGE / 3;

    // fix the coordinate points and supplement top.

    int x = 0;

    int y = 0;

    // firm the hue and appoint the rectangle

    page.setColor(Color.BLUE);

    page.fillRect(x, y, WIDTH_Of_PAGE, Top);

    page.setColor(Color.WHITE);

    y += Top;

    // firm the hue and appoint the rectangle

    page.fillRect(x, y, WIDTH_Of_PAGE,Height);

    page.setColor(Color.BLUE);

    y +=Height;

    page.fillRect(x, y, WIDTH_Of_PAGE, Top);

    }

    // specification of the system epistlek(Graphics page)

    open wanting epistleK(Graphics page) {

    int Width = WIDTH_Of_PAGE / 2;

    // fix the coordinate points and supplement Width.

    int xCordinate = 0;

    int yCordinate = 0;

    // firm the hue and appoint the rectangle

    page.setColor(Color.YELLOW);

    page.fillRect(xCordinate, yCordinate, Width, HEIGHT_OF_PAGE);

    page.setColor(Color.BLUE);

    xCordinate += Width;

    // firm the hue and appoint the rectangle

    page.fillRect(xCordinate, yCordinate, Width, HEIGHT_OF_PAGE);

    }

    // specification of the system epistleP(Graphics page)

    open wanting epistleP(Graphics page) {

    int borderWidth = 30;

    page.setColor(Color.BLUE);

    page.fillRect(0, 0, WIDTH_Of_PAGE, HEIGHT_OF_PAGE);

    page.setColor(Color.WHITE);

    page.fillRect(borderWidth, borderWidth, WIDTH_Of_PAGE – borderWidth * 2,

    HEIGHT_OF_PAGE – borderWidth * 2);

    }

    // specification of the system epistleU(Graphics page)

    open wanting epistleU(Graphics page) {

    page.setColor(Color.WHITE);

    page.fillRect(0, 0, WIDTH_Of_PAGE, HEIGHT_OF_PAGE);

    int boxWidth = WIDTH_Of_PAGE / 2;

    int boxTop = HEIGHT_OF_PAGE / 2;

    int xCordinate = 0;

    int yCordinate = 0;

    page.setColor(Color.RED);

    page.fillRect(xCordinate, yCordinate, boxWidth, boxHeight);

    xCordinate += boxWidth;

    yCordinate += boxHeight;

    page.fillRect(xCordinate, yCordinate, boxWidth, boxHeight);

    }

    // specification of the system epistleX(Graphics page)

    open wanting epistleX(Graphics page) {

    page.setColor(Color.WHITE);

    page.fillRect(0, 0, WIDTH_Of_PAGE, HEIGHT_OF_PAGE);

    int characterX = WIDTH_Of_PAGE/2;

    int characterY = HEIGHT_OF_PAGE/2;

    int barThickness = 30;

    //coordinates restraint perpendicular bar

    int vertBarX = characterX – barThickness / 2;

    int vertBarY = 0;

    page.setColor(Color.BLUE);

    page.fillRect(vertBarX, vertBarY, barThickness, HEIGHT_OF_PAGE);

    //coordinates restraint insipid bar

    int horzBarX = 0;

    int horzBarY = characterY – barThickness / 2;

    page.fillRect(horzBarX, horzBarY, WIDTH_Of_PAGE, barThickness);

    }

    }