Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439

This lab sheet contains work that is to be submitted for assessmentand will contribute to 3% of the finalmark in this unit.

Submission is via

Details concerning what must be undertaken and submitted are given below.

Assessed Lab - Flags of the World

Acknowledgement: the flag pictures and information come from the. Theflag selection was based purely on the suitability of the images fora computer graphics project.

In this lab we will write a class called FlagDrawer thatwill have methods for drawing a variety of flags. In the lab session, we will help for drawing the first 10 flags (the Libya flag is excluded). You must be very creative if you want get the full marks. Do as many of themas you can!

For example, the Luxembourg flag (height:width 3:5) looks like this:

We could draw it as follows:

public void drawLUX(int width) {  int height = width * 3 / 5;  SimpleCanvas c = new SimpleCanvas("Luxembourg flag", width, height);  // This draws the top stripe as a bunch of horizontal lines  c.setForegroundColour(java.awt.Color.red);  for (int i = 0; i < height/3; i++) {    c.drawLine(0, i, width, i);  }  // This draws the bottom stripe the same way   c.setForegroundColour(java.awt.Color.cyan);  for (int i = height * 2 / 3; i < height; i++) {    c.drawLine(0, i, width, i);  }}

Make sure you understand drawLUX before you start.Note the following.

  1. Flags come in different aspect ratios, so ratherIn the lab session, we will help for drawing the first 10 flags (the Libya flag is excluded). You must be very creative if you want get the full marks!than having the SimpleCanvas being an instance variable ofFlagDrawer, we will get eachmethod to create its own SimpleCanvas with the correctproportions.Each method takes as its argument the width of the flag, then it sets the height accordingly. Your methods must work for any reasonable value of width.
  2. This flag was drawn with height/3horizontal red lines at the top andthe same number of horizontal cyan lines at the bottom, leaving (notionally) white lines in-between.
  3. The method uses java.awt.Color for the standard colours used here. You can access the interface and documentation for this class from the BlueJ Tools menu. The class also provides methods for constructing less common colours: probably easiest to use is the Color constructor that takes three ints. (Your colours don't need to be absolutely precise, though.)
  4. When the method finishes, the local variable c will bedestroyed; however the actual window on your screen will not bedeleted. This means that if you call the method again, youwill get a new window.

Very, Very Easy Flags

  1. Libya (LY)(height:width 1:2)

Easy

  1. Ukraine (UKR)(height:width 2:3)

  2. France (FR)(height:width 2:3)

  3. Thailand (TH)(height:width 3:5, stripes 1:1:2:1:1)

  4. Gambia (GA)(height:width 2:3, stripes 3:2:3 plus gaps)

Medium

  1. UAE (UAE)(height:width 1:2, the red is 1/4 of the width)

  2. Finland (FI)(height:width 11:18, the stripe is 1/7 of the width and centred 1/3 of the way along)

  3. Switzerland (SW)(height:width 1:1, the cross breaks the flag symmetrically into fifths)

Getting harder

  1. Congo-BrazzaVille (CB) (height:width 2:3, the yellow is 1/3 of the width)

  2. Seychelles (SY)(height:width 1:2, the diagonals break the width and height into thirds)

  3. Scotland (SC) (height:width 3:5, each arm of the cross is 1/5 of the width)

Hard

  1. Qatar (Q)(height:width 11:28, the dashes are centred 1/3 of the way along)

  2. South Africa (SA)(height:width 2:3, measure it yourself!)

  3. Japan (JP)(height:width 7:10, the circle is centred and its diameter is 1/3 of the width)

  4. Greenland (GD)(height:width 2:3, the "circle" is 10% off-left and its diameter is 1/2 of the width)

  5. Western European Union (WEU)(height:width 2:3)

Really quite hard indeed

  1. South Korea (SK)(height:width 2:3)

  2. Algeria (AG)(height:width 2:3)

  3. Antigua & Barbuda (AB)(height:width 2:3)

Don't even bother!

  1. Hong Kong (HK)(height:width 2:3)

  2. Albania (AN)(height:width 5:7)

  3. Wales (WS)(height:width 3:5)

Specification

The FlagDrawer class should implement as many of the following methods as you can.

  1. public void drawUKR(int width)
  2. public void drawFR(int width)
  3. public void drawTH(int width)
  4. public void drawGA(int width)
  5. public void drawUAE(int width)
  6. public void drawFI(int width)
  7. public void drawSW(int width)
  8. public void drawCB(int width)
  9. public void drawQ(int width)
  10. public void drawSC(int width)
  11. public void drawSY(int width)
  12. public void drawJP(int width)
  13. public void drawGD(int width)
  14. public void drawSA(int width)
  15. public void drawSK(int width)
  16. public void drawAG(int width)
  17. public void drawAB(int width)
  18. public void drawHK(int width)
  19. public void drawAN(int width)
  20. public void drawWS(int width)

Each method should drawthe flag of the country whose code is in the method name. You may just omit the methods you do not want to submit.The final exam usually contains a flag-drawing question, so selecting only the easiest flags is likely to be costlyin the long run. Also notice that the Libyan flag is deliberately omitted from your list of choices.

You must ensure that your method signatures match the above or they will not be marked. No validator is provided, and no JUnit tests are provided: test your methods by inspecting the flags drawn for various values of width. We recommend that you follow the CS-readability checkstyle rules.

Marking

Marks will be allocated as follows:

Your flags do not have to be pixel-perfect, but they must be clearly recognisable by eye. You must have roughly the right colours, and the right markings with roughly the right shapes and dimensions.