CSE 131 Module 4: Input & Output

Studio


If necessary, review studio procedures before starting.

Warmup

Thanks to Emily Feng for this link to a Ted Talk about flag design.

Overview

In honor of the upcoming UN Day, you will select (or design) a flag of your choice and create that flag using the drawing methods available in Sedgewick's library.
Here is the one I created:
But I am certain you will be much more creative!

Resources

You may find the following resources helpful for this studio:
Warning The book is missing some of the functionality that is in the Sedgewick library. For example, the book is missing the method that draws a filled rectangle, and that can be useful for drawing a flag.

See the link above for the full range of possibilities.

Procedure

Design your country
Thinking through these questions may help guide the design of your country's flag and anthem.

Design your flag
  1. Visit the Flags of all Countries web site, and decide on a flag that your studio group would like to create for this studio.
    Design (or pick) a flag that has at least 3 shapes on it. If you need to approximate something by a standard shape, such as a maple leaf by a circle, that's fine: just claim that your flag is somewhat abstract.

    If you want to design your own flag, that's fine. Make sure it has at least 3 shapes in it. Try to come up with a cool name for your flag's country.

  2. Open the studio4 package int he studios source folder, and open the Flag class.
    • That class is currently empty except for the main.
    • Insert code that creates the flag of your choice.
      Notes:
      • Most of the drawing methods want the center of the object to be drawn, along with a radius, or a half-width, or a half-height. Be aware of this!
      • If you want colors, they are already in the Sedgewick libraries. If you start to type something like:
        sedgewick.
        
        then eclipse will fill in possiblities after the . which will include the colors at the top of that list.
    • Frame your flag by surrounding it by a black rectangle of substantial thickness, (unfilled).
    • When done, allow your studio neighbors and TAs to admire its beauty.
Display the name of your country
  1. In the center of your flag, using a color that allows the text to stand out, write the name of your country on top of your flag.
  2. In a (literally) moving display of patriotism, arrange for your program to print the name of your country repeatedly, from the upper-left-hand corner to the lower-right-hand corner.
    For more drama, pause for a bit between each printing of the country's name, to allow for cheering from the crowd. Take a look at the show(int t) method to achieve the pause.
Compose an anthem for your flag
  1. Find the PlayThatTune program in the coursesupport source folder, in the book.ch1 package.
  2. Run the program and make sure you can hear some sound when you play a given piece.
    The music inputs come from the music folder in your workspace. The program lets you choose any of the files in that directory, or you can navigate elsewhere if you wish.
  3. Based on what you see in the Ascale.txt file, design a piece that is your own anthem by specifying the pitches and durations.
    You can do this by modifying an existing file in the music folder (for example, there is already a National_Anthem.txt file, so you can just modify that), or you can create a new text file in that same folder and place your composition there.

    If you are really unclear how to do this, no problem, you can just use one of the existing compositions.

    Or, you could generate tones and durations randomly. Pick values that seem similar to what you see in the music files.

  4. Try PlayThatTune and select your composition for playing.
  5. Once you like it, copy and paste the appropriate code from PlayThatTune into your Flag program so the anthem plays after your flag and text are drawn.
    • The code you want is everything inside the main method; get help if necessary.
    • When you run your code, you will have to select the anthem by hand.
    • If you want the file to open without the user having to choose it, then replace the line
      ArgsProcessor.useStdInput("music");
      
      with
      System.setIn(new FileInputStream("music/National_Anthem.txt"));
      
      Eclipse will provide guidance about importing the right classes so this will work.
  6. See if you can figure out how to get your anthem to play repeatedly.
    This may not seem easy, but it builds on what you know about arrays and iteration.

Submitting your work (read carefully)



Last modified 05:16:47 CDT 27 September 2017
When you done with this studio, you must be cleared by the TA to receive credit.

This demo box is for studio 4
Last name WUSTL Key Propagate?
(NOT your numeric ID) Do not propagate
lower case only
e.g. Smith j.smith
1 Copy from 1 to all others
2 Copy from 2 to all others
3 Copy from 3 to all others
4 Copy from 4 to all others

Acknowledgements and assertion of integrity

You must select one of the options below
The work submitted here was performed in accordance with this course's policy on collaboration.
On your honor, you have neither given nor received any unauthorized aid on this assignment.

However, the following TAs, students, or professors were supportive in completing this assignment.
Their help was also in accordance with course policies.

Thanks to (leave blank if appropriate):

In spite of seeking help as allowable by this course's policy on collaboration, you were unable to complete this assignment. No credit will be received for this assignment.

You would like to be contacted by an instructor to facilitate staying on track in this course.

Comments about this:

You have NOT abided by this course's policy on collaboration. No credit will be received for this assignment, but by checking this box, no academic integrity violation will be filed for this assignment.

You would like to be contacted by an intructor to faciliate staying on track in this course.

Comments about this:


TA: Password: