Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

these are the questions above and some sample outputs down below More Fun with Flags (GUIs and Inheritance) Summary Create three JPanel flags and use

image text in transcribed

image text in transcribed

image text in transcribed

these are the questions above and some sample outputs down below

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

More Fun with Flags (GUIs and Inheritance) Summary Create three JPanel flags and use the FlagFrame class provided to display them. FlagFrame.java The first flag may be just stripes (horizontal or vertical), but the other two must be more interesting. I have provided two example JPanel flags: GermanFlag.java French Flag.java You can see the resulting windows in the sample output. In order to make sure your code runs when submitted, name the flag classes: FlagOne . Flag Iwo Flag Three Do not name them after the countries! Details The class FlagFrame represents a GUI designed hold a flag image. You need to put that class into your A04 project, but don't change it (except you may change or delete the package command). Your task in this assignment is to create three classes that extend JPanel such that each one draws a flag. In order to do that, your class needs to: Have a constructor that sets the preferred width and height of the flag and sets the name of the flag Implement the paint Component (Graphics g) method. This method uses methods from the class Graphics to draw the flag itself Have a main method that creates and shows a FlagFrame object. The FlagFrame constructor needs to be given the flag object you've designed. See the sample flags for examples of the above. Notes For the constructor Notes For the constructor: The command to set the preferred size of the flag is setPreferredSize (new Dimension (width, height)); You need to specify what width and height are, but they must be integers. The command to set the name of the flag is setName (countryName); The country name must, of course, be a String, and it will be placed in the title of the flag GUI. For paintComponent, I would like you to stick to the following methods: setColor (colour) fillRect (across, down, width, height) filloval(across, down, width, height) fillArc(across, down, width, height, start, distance) fillPolygon (acrosses, downs, numCorners) fillPolygon (a Polygon) In each of those methods: colour is a java.awt.Color across is an int saying how far across the flag the "left edge" of the object is down is an int saying how far down the flag the "top edge" of the object is width is an int giving the left-to-right size of the object height is an int giving the top-to-bottom size of the object start is an angle (O means straight out to the right, 90 is straight up, and -90 is straight down) distance is another angle, with positive indicating counter-clockwise direction acrosses and downs are int arrays of the same length representing how far across the flag and down the flag each corner of the polygon is nuraCorners says how many corners the polygon has . a Polygon is a Polygon object To draw in colour, you need to set the colour just before you start drawing the objects. Note that later objects are drawn over earlier objects, a fact I used in both the sample flags to colour in the central stripe. I made the whole flag the colour of the central stripe, then added to other stripes on top of that colour. If you're clever, you can use that fact to create a crescent in your flag by drawing one oval on top of another. Grading Outline In each of those methods: colour is a java.awt.Color across is an int saying how far across the flag the "left edge" of the object is down is an int saying how far down the flag the "top edge" of the object is width is an int giving the left-to-right size of the object height is an int giving the top-to-bottom size of the object start is an angle (O means straight out to the right, 90 is straight up, and -90 is straight down) distance is another angle, with positive indicating counter-clockwise direction acrosses and downs are int arrays of the same length representing how far across the flag and down the flag each corner of the polygon is nurCorners says how many corners the polygon has Polygon is a Polygon object To draw in colour, you need to set the colour just before you start drawing the objects. Note that later objects are drawn over earlier objects, a fact I used in both the sample flags to colour in the central stripe. I made the whole flag the colour of the central stripe, then added to other stripes on top of that col- If you're clever, you can use that fact to create a crescent in your flag by drawing one oval on top of another. Grading Outline Your assignment will be graded out of 100. Files with the wrong name will be penalized 10 points. Code that does not compile will be penalized 10 points plus 5 points for each line that needs to be fixed. Up to 30 points may be deducted for code that does not meet the standard requirements described in the rules for submissions and the style rules. Up to 30 points may be deducted for code that does not follow the design described above and the general good design principles. Up to 100 points may be deducted for code that does not perform properly. Yes, that is well over 100 points of possible deductions. Doing half the job is not going to get you have the credit. You need to do good work as a matter of course; only excellent work will get full credit. SUBMIT / Check Sixth Sample Flag (Canada) Because I like the challenge. 1 Canada x Note: I could not find an "official" description of this flag, so this is just my attempt to recreate what I see in on-line images. At least one site says the flag should be tall instead of wide, but I have portrayed it the way it is usally seen flying on flagpoles around Mi'kma'ki. Mi'kmaq Grand Council - Fourth Sample (Jamaican) Jamaican Third Sample (Bahamian) Bahamas More Fun with Flags (GUIs and Inheritance) Summary Create three JPanel flags and use the FlagFrame class provided to display them. FlagFrame.java The first flag may be just stripes (horizontal or vertical), but the other two must be more interesting. I have provided two example JPanel flags: GermanFlag.java French Flag.java You can see the resulting windows in the sample output. In order to make sure your code runs when submitted, name the flag classes: FlagOne . Flag Iwo Flag Three Do not name them after the countries! Details The class FlagFrame represents a GUI designed hold a flag image. You need to put that class into your A04 project, but don't change it (except you may change or delete the package command). Your task in this assignment is to create three classes that extend JPanel such that each one draws a flag. In order to do that, your class needs to: Have a constructor that sets the preferred width and height of the flag and sets the name of the flag Implement the paint Component (Graphics g) method. This method uses methods from the class Graphics to draw the flag itself Have a main method that creates and shows a FlagFrame object. The FlagFrame constructor needs to be given the flag object you've designed. See the sample flags for examples of the above. Notes For the constructor Notes For the constructor: The command to set the preferred size of the flag is setPreferredSize (new Dimension (width, height)); You need to specify what width and height are, but they must be integers. The command to set the name of the flag is setName (countryName); The country name must, of course, be a String, and it will be placed in the title of the flag GUI. For paintComponent, I would like you to stick to the following methods: setColor (colour) fillRect (across, down, width, height) filloval(across, down, width, height) fillArc(across, down, width, height, start, distance) fillPolygon (acrosses, downs, numCorners) fillPolygon (a Polygon) In each of those methods: colour is a java.awt.Color across is an int saying how far across the flag the "left edge" of the object is down is an int saying how far down the flag the "top edge" of the object is width is an int giving the left-to-right size of the object height is an int giving the top-to-bottom size of the object start is an angle (O means straight out to the right, 90 is straight up, and -90 is straight down) distance is another angle, with positive indicating counter-clockwise direction acrosses and downs are int arrays of the same length representing how far across the flag and down the flag each corner of the polygon is nuraCorners says how many corners the polygon has . a Polygon is a Polygon object To draw in colour, you need to set the colour just before you start drawing the objects. Note that later objects are drawn over earlier objects, a fact I used in both the sample flags to colour in the central stripe. I made the whole flag the colour of the central stripe, then added to other stripes on top of that colour. If you're clever, you can use that fact to create a crescent in your flag by drawing one oval on top of another. Grading Outline In each of those methods: colour is a java.awt.Color across is an int saying how far across the flag the "left edge" of the object is down is an int saying how far down the flag the "top edge" of the object is width is an int giving the left-to-right size of the object height is an int giving the top-to-bottom size of the object start is an angle (O means straight out to the right, 90 is straight up, and -90 is straight down) distance is another angle, with positive indicating counter-clockwise direction acrosses and downs are int arrays of the same length representing how far across the flag and down the flag each corner of the polygon is nurCorners says how many corners the polygon has Polygon is a Polygon object To draw in colour, you need to set the colour just before you start drawing the objects. Note that later objects are drawn over earlier objects, a fact I used in both the sample flags to colour in the central stripe. I made the whole flag the colour of the central stripe, then added to other stripes on top of that col- If you're clever, you can use that fact to create a crescent in your flag by drawing one oval on top of another. Grading Outline Your assignment will be graded out of 100. Files with the wrong name will be penalized 10 points. Code that does not compile will be penalized 10 points plus 5 points for each line that needs to be fixed. Up to 30 points may be deducted for code that does not meet the standard requirements described in the rules for submissions and the style rules. Up to 30 points may be deducted for code that does not follow the design described above and the general good design principles. Up to 100 points may be deducted for code that does not perform properly. Yes, that is well over 100 points of possible deductions. Doing half the job is not going to get you have the credit. You need to do good work as a matter of course; only excellent work will get full credit. SUBMIT / Check Sixth Sample Flag (Canada) Because I like the challenge. 1 Canada x Note: I could not find an "official" description of this flag, so this is just my attempt to recreate what I see in on-line images. At least one site says the flag should be tall instead of wide, but I have portrayed it the way it is usally seen flying on flagpoles around Mi'kma'ki. Mi'kmaq Grand Council - Fourth Sample (Jamaican) Jamaican Third Sample (Bahamian) Bahamas

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 2 Lncs 8056

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013th Edition

3642401724, 978-3642401725

More Books

Students also viewed these Databases questions