CSE 131 Module 4: Input & Output
If necessary, review studio procedures before
First, form a group:
- If you are at a table with a large, wall-mounted screens, a group of 3-4 people is fine.
- If you are seated at a table without a large screen, a group of 2 people is better.
- All but one member of your group should have this web page open so you can follow along
and see the instructions as you work.
- All members of the group should update their repositories:
- Open your repository in eclipse
- Right-click (control-click on a mac) on your repository name
- Drag down to Team...
- Choose Update
- Supply your WUSTL key and password as necessary
- Plan to have one computer at which your team does its work. Initially,
one of you will be in charge of typing at that computer.
- Throughout the studio, you should trade who is in charge of the keyboard. Before doing so,
commit your work to make sure your work is saved.
Thanks to Emily Feng for this link to a Ted Talk about flag design.
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!
You may find the following resources helpful for this studio:
- Slides from lecture. (Also
available in PDF)
- Lecture code that you will find in your (studio and personal) repositories,
in the lecture source folder, in the mod4sect1
- The API
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.
- Design your country
Thinking through these questions may help guide the design of your country's flag
- What are the founding principles of your country?
- What is your country's motto?
- What major exports do you envision for your country?
- Who might be valuable allies for your country?
- Does your country have its own
- Design your flag
- 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.
- 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.
- 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:
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
- 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.
- 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
- Find the PlayThatTune program in the book source folder, in the book.ch1 package.
- 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.
- 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.
- Try PlayThatTune and select your composition for playing.
- 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.
- 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
Submitting your work (read carefully)
- If your studio contains a feedback.txt file, respond to
the questions and supply any requested information.
- You must commit all of your work to your repository. It's best to do this
from the top-most level of your repository, which bears your name and student ID.
- Follow the instructions in the green box below to receive credit for your work.
Last modified 09:52:56 CDT 16 May 2016
When you done with this studio, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately,
but should be posted in the next day or so
This demo box is for studio 4