Preliminary statement of HW6 for 221 and HW4 for 473.
Added 11.12.2005:
It's not all that hard, once you assemble the ideas. For a tutorial on
split,
try
http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter10/stringBufferToken.html.
(That's Sweden. Don't you love the Internet?)
Or Google for java split example . You'll see that split is a much simpler way to do what StringTokenizer does, unless you need some things that StringTokerizer does that split doesn't. (We don't.)
For a tutorial on writing to a file instead of to the console try http://www.cs.geneseo.edu/~baldwin/reference/java-textio.html.
(And that's the State University of New York College at Geneseo, near Rochester.)
Once you have your musician's bio as a string, breaking it into paragraphs is a matter of one line, with a split method (of String) that uses a regular expression to break the string into smaller strings in an array. Writing the HTML for a page about your musician is a matter of 15-25 lines, depending on whether you put all the opening HTML into one string or into enough strings so that the HTML would look like HTML usually does.
Added 11.11.2005: Thanks to Chae Lim and whoever else (sorry I don't remember who) nailed the problem with the biographical strings: there were typographic quotes mixed in with the straight quotes. (In case you've never noticed, the opening and closing quotes in books and newspapers etc. are not the same.) A straight quote is a different character, in ASCII, than either of the typographic quotes. Thanks also to whoever told me how to replace as character that I can't type: copy one from the text. I've replaced everything about the text and the sample program, in what appears at the end of this page.
Added 11.9.2005 for both courses: A main purpose of this assignment is to give you a little hint of the power of Java collections. Lists, sets, and maps, each with several implementations and with lots of algorithms where appropriate (sort, for example)--these provide great power with relatively little effort. I can't imagine why you would ever write a sort routine, or program insertion into and retrieval from a binary search tree. Stacks, queues, and priority queues are all available for the trouble of looking them up in the API. Collections have never before been taught in a required course at City College, and only a very few times in any course. That omission needs correcting.
You get a glimpse in this assignment. Collections will be covered thoroughly in my Advanced Java in the spring. If you're guessing that so much power entails a learning curve, you are right. We'll whip them into submission.
I can't seem to put the ArrayList and HashMap sample
code into this page. I'll email it to everybody as an attachment.
Done.
473: due Tuesday, Nov 15. This date is firm, and the assignment will not grow. Holes will be patched, but no major additions. We gotta get on to database. You can and probably should do this as a standalone assignment, to get a little experience with collections, and maybe build it into your web app later. Probably.
473 Added 11.9.2005: Consider writing HTML code to a file, as the output of your program. This is a variation of what a servlet does, with the added requirement to look up the basics of file Java I/O. That's an omission that needs correction, too. But the due date is still next Tuesday, and this is still a side trip away from our goal of getting great projects completed, so that's optional.
221 Added 11.9.2005: We will learn how to write the output of your program, after you offer the user a choice of musicians and the user picks one, to a file, with all the tags needed to make a valid HTML file. The output will then come up in a browser window.
Please bear in mind that you must program the separation of the long strings into paragraphs. No fair doing anything "by hand." Learning how to use the StringTokenizer or the split method of String, with regular a regular expression.
And we will, of course, have to learn how to write output to a file. Worth knowing anyway.
Both of the 221 dates are also firm, but there may be "enhancements." (In
real life, specs change constantly. Get used to it.) No more changes.
221 Added 11.11.2005: Well, not firm. We spent highly useful time in both sections going over the midterm. You deserve one more class, on file I/O and on the split method of String, before wrapping this up. So I'll extend the due dates until Thanksgiving week. But we definitely start working on the final project next week (Nov. 14-18).
221G due Wednesday Nov 16. Monday, November 21.
221P due Thursday Nov 17. Tuesday, November 22.
Build a HashMap with a musician's name as the string key, and the long paragraph below as the value. Then provide a retrieval system in which the user asks for a musician and gets the bio in nicely formatted console output. (Or a text box, if you have time.) "Nicely formatted" means only that you have to use a regular expression with a String tokenizer or a String split method to replace the = delimiters with paragraph breaks.
In the code that follows, I replaced all paragraph marks with =. You can use a regular expression to break the string apart for display when the string is retrieved from a map. Well, not exactly all; some students hit the carriage return twice to get extra space between paragraphs. I replaced all such with a single paragraph mark. All quotes are escaped: " becomes \".
The String Maxwell, below, rejected by Eclipse. See note with the string.
Hmmm. Now I comment that one out, and it rejects Miles. Something else going on
here.
package hashMap;
import java.util.ArrayList;
import java.util.HashMap;
public class Testing2 {
public static void main(String[] args) {
ArrayList<String> music = new ArrayList();
ArrayList<String> descript = new ArrayList();
music.add("Johnny Hartman");
String JohnnyHartman = "Though he was never the most distinctive vocalist,
Johnny Hartman rose above others to become the most commanding, smooth balladeer
of the 1950s and '60s, a black crooner closely following Billy Eckstine and
building on the form with his notable jazz collaborations, including the 1963
masterpiece John Coltrane and Johnny Hartman. Born in Chicago, he began singing
early on and performed while in Special Services in the Army. Hartman studied
music while at college and made his professional debut in the mid-'40s,
performing with Earl Hines and recording his first sides for Regent-Savoy. After
Hines' band broke up later in 1947, Hartman moved to the Dizzy Gillespie Big
Band and stayed for two years, recording a few additional sides for Mercury as
well. Johnny Hartman's first proper LP came in 1956 with Songs From the Heart,
recorded for Bethlehem and featuring a quartet led by trumpeter Howard McGhee.
He recorded a second (All of Me) later that year, but then was virtually
off-record until 1963, when his duet album John Coltrane and Johnny Hartman
appeared on Impulse. A beautiful set of ballad standards, including top-flight
renditions of \"Lush Life\" and \"My One and Only Love,\" the album sparked a
flurry of activity for Hartman, including two more albums for Impulse: 1963's I
Just Dropped by to Say Hello and the following year's The Voice That Is. During
the late '60s and early '70s, he recorded a range of jazz and pop standards
albums for ABC, Perception, and Blue Note. Hartman recorded sparingly during the
1970s, but returned with two albums recorded in 1980, one of which (Once in
Every Life) earned a Grammy nomination just two years before his death in 1983.
(Taken from www.vh1.com)";
String Maxwell = "In an age where young, black artist are criticized (often
rightly so) for misogynistic lyrics, Maxwell's focus on commitment is
refreshing. But more important, he can flat-out sing. His talent, combined with
great songs, an engaging personality and a mesmerizing live show, has brought
comparisons to great soul men, such as Marvin Gaye.=The young singer brushes off
comparisons to legends of the past, considering them premature. \"It's a nice
compliment, but I don't really hold it as truth,\" he says. His speaking voice
is his singing voice: soft, scratchy and filled with a quiet confidence that
belies his humble words. \"I'm only one album deep,\" he adds. \"Give me seven
albums, then we could probably sit down and talk about something like that. But
the reaction that I've received blows my mind, and it's such a big blessing. I
always say thank-you to God 'cause I never expected anyone to really get into it
as much as people say they have.\"=Maxwell's critically acclaimed debut album,
Urban Hang Suite (Columbia, 1996), which the 22-year-old singer says is
autobiographical, chronicles the story of a chance encounter between him and an
unnamed woman. After Maxwell, with his raspy voice and soothing falsetto,
whispers a sweet, seductive entreaty to lose himself \"inside her ebony,\" she
eventually becomes his soul mate, and the album ends with a marriage
proposal.=Like many of his urban music contemporaries, Maxwell sprinkles his
conversation with frequent references to a higher being. Born to Caribbean
parents and raised Baptist in a tough and blighted section of East New York, he
grew up in the church, attending as often as five times a week. But
surprisingly, given his present success, choir practice wasn't a part of his
religious activity. In fact, no one even knew that he could sing. \"They
probably all thought I was mute,\" he says with a chuckle. \"I never spoke much.
I just didn't feel as though I had anything to say until music came into my
life; that was when the bridge came, and that was when I had something to speak
about.\" (taken from American Visions )";
String Bach = "J.S. Bach was born in Eisenach, Germany, in 1685 and died in 1750
(he was 65 when he died). He came from a long family history of professional
muscicians including church organists and composers. Like his father, Johann
Ambrosius Bach, J.S. (Johann Sebastian) would learn and surpass him in this art
of classical music composing.=Bach's childhood wasn't that great as his father
passed away when he was 9 and his mother also died when he was a young boy.
Although he spent much time with his musically inclined uncles, he also spent
time studying and learning from his older brother, Johann Christoph
Bach.=Growing up, Bach learned much about organ building. Back in those days,
the church organ was a highly complex instrument with many mechanical and moving
parts and pedals and pipes. His early experience with repairing and talking with
organ builders & performers would prove valuable as he mastered the musical
craft.";
String BarryWhite = "Barry Eugene Carter (a.k.a. Barry Lee) 12th September 1944,
Galveston, Texas, U.S.A. Barry White was born in Galveston, Texas, but raised in
Los Angeles. Barry's mother's name was Sadie Mae Carter, however, his father's
surname was White. He was involved in the local music community while still very
young, playing piano on Jesse Belvin's hit 'Goodnight my Love' at the age of
11.Barry recorded his first record when he was 16 with a group called the
Upfronts. The song was called 'Little Girl' on a local L.A. label called
Lummtone Records. Barry made several records during the early 60's, under his
own name, as 'Barry Lee', and as a member of the Atlantics, the Majestics as
well as the Upfronts. Following on Barry worked for various independent labels
around Los Angeles. He was also a producer and road manager for Bob and Earl.
Barry took an A and R position with Bob Keene, the man who first recorded Sam
Cooke. He was hired for 40 dollars a week to do A.and.R for Keene's other
labels, Mustang and Bronco. Barry recorded a record for Bronco called 'All in
the Run of a Day.' One of the first groups he worked with was the Versatiles who
later became the 5th Dimension. Barry found a greater success as a backroom
figure, guiding the careers of, among others, Felice Taylor, recording 'It May
Be Winter Outside,' 'I'm Under the Influence of Love,' and 'I Feel Love Coming
On', and Viola Wills ('Lost Without the Love of My Guy', Top 20 R and B).=In
1969, he put together Love Unlimited, a female vocal trio made up of Diana
Taylor, Glodean James (his future wife) and her sister Linda. He also founded
the Love Unlimited Orchestra, a 40-piece ensemble to accompany himself and the
singing trio, for which he conducted, composed and arranged. Love Unlimited's
success, in 1972, with 'Walkin' In The Rain With The One I Love', featuring his
voice on the telephone, rejuvenated Barry's own career. The hits followed
including 'I'm Gonna Love You Just A Little More', 'Never, Never Gonna Give You
Up' (both 1973), 'Can't Get Enough Of Your Love, Babe' and 'You're The First,
The Last, My Everything' (both 1974) all of which proved popular in the U.K. and
the U.S.A. alike. Barry had a major hit in 1978 with Billy Joel's song 'Just The
Way You Are'. He later undertook several recordings with Glodean White before
returning to the UK Top 20 in 1987 with 'Sho' You Right'. Barry's achievements
during the peak of his career, in securing gold and platinum discs for worldwide
sales is impressive.=In 1990, he was a featured vocalist on the Quincy Jones
project 'Back On The Block' , contributing to the song 'The Secret Garden'. Lisa
Stansfield has often voiced her approval of Barry's work and in 1992, she and he
re-recorded a version of Stansfield's hit 'All Around The World'. In 1999, Barry
returned with 'Staying Power' containing the popular 'Which Way Is Up'. He,
also, took a cameo role in the television series Ally McBeal, where his
recordings were pivotal to many of the series storylines. Barry's godson is the
singer and songwriter Chuckii Booker. In 2002, Barry was admitted into hospital
and underwent kidney dialysis following kidney failure afrer suffering years of
high blood pressure. Barry had suffered two strokes, the latest of which
occurred in May 2003.=Barry White, who had suffered kidney failure from years of
high blood pressure, died at Cedars-Sinai Medical Centre, Los Angeles, around
9.30am local time, on the 4th of July 2003, said his manager Ned Shankman. He
was 58. (taken from www.soulwalking.com )=";
String Mozart = "(born Salzburg, 27 January 1756; died Vienna, 5 December 1791).
Son of Leopold Mozart. He showed musical gifts at a very early age, composing
when he was five and when he was six playing before the Bavarian elector and the
Austrian empress. Leopold felt that it was proper, and might also be profitable,
to exhibit his children's God-given genius (Maria Anna, 'Nannerl', 1751-1829,
was a gifted keyboard player): so in mid-1763 the family set out on a tour that
took them to Paris and London, visiting numerous courts en route. Mozart
astonished his audiences with his precocious skills; he played to the French and
English royal families, had his first music published and wrote his earliest
symphonies. The family arrived home late in 1766; nine months later they were
off again, to Vienna, where hopes of having an opera by Mozart performed were
frustrated by intrigues.";
String Chopin = "Perhaps the greatest of all composers for the piano was Chopin.
Called a \"musical genius\" when he was a teenager, Chopin composed a remarkable
variety of brilliant pieces warlike polonaises, elegant waltzes, romantic
nocturnes, and poetic ballades and etudes. His father, Nicholas, was a Frenchman
who had lived in Poland for many years. His Polish mother was of noble birth.
Even as a small child, Chopin loved piano music. He began to take piano lessons
when he was 6 years old. He started to compose music even before he knew how to
write down his ideas. At the age of 8 he performed in a public charity concert.
Chopin's first published musical work, a rondo, appeared when he was 15 years
old. When Chopin graduated from the lyceum, at 17, he was recognized as the
leading pianist of Warsaw and a talented composer.=After Chopin gave two
successful concerts in Vienna when he was 19, he began writing works designed
for his original piano style. At the same time as his return to Vienna in 1830,
Poland revolted against its Russian rulers. The uprising failed, and as a result
the Russian czar put Warsaw under harsh military rule. Chopin decided to go to
Paris, which was the center of the romantic movement in the arts. Except for
occasional trips, Chopin spent the rest of his life in Paris. He gave lessons
and concerts, and publishers paid well for his compositions. The French loved
him for his genius and his charm. Poets, musicians, wealthy Parisians, and
Polish exiles were his friends. An important influence was a romantic friendship
with Baroness Dudevant, better known as the novelist George Sand.=Chopin died of
tuberculosis, at age 39.=He wrote few concertos and sonatas. Instead he
perfected freer musical forms. Among his compositions are some 50 mazurkas, 25
preludes, 24 etudes, 21 nocturnes, 17 waltzes, 11 polonaises, 4 ballades and 3
sonatas. For his polonaises and mazurkas he used the rhythms and spirit of
Polish folk dances. Maybe your nocturnes are their master pieces.";
descript.add(JohnnyHartman );
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("Johnny Hartman", JohnnyHartman);
String bio = hm.get("Johnny Hartman");
System.out.println(bio);
}
}