1A
If you have not done so, create the directory structure specified in Lab0.
Start a new Bluej project called hw1a_cats
in the cs46a/homeworks/drafts/hw1
folder. Create a new class called Cats (you must use this exact name). You will display the word cat in three different languages: English, Spanish, and Japanese Hiragana.
Go to the draft link at the bottom of the page. Copy the code given into the Cats class.
Complete the class to draw the figure exactly as shown.
The first row is *----*
second row is *cat
third row is *gato
the fourth row has an * and then the two hiragana characters
th last row is the same as the first
For the draft, just print the first two lines like this
*----*
*cat
When you are ready to work on the final, copy the Bluej project (hw1a_cats
) into the cs46a/homeworks/finals/hw1
folder. Open the project from Bluej and complete the assignment.
The fourth line in the printout needs more explanation. This is the word for "cat" in the Japanese hiragana writing system. It is pronounced "neko" But how do we get those squiggly lines? Well, every printable character in English and most other languages is represented by a hexidecimal number (it is called unicode). When you type a character on your keyboard, the computer software takes care of translating the character to its unicode representation. But when we want to display a character that is not on the keyboard, we have to supply the unicode ourselves. We could also specify the English charaters directly with unicode. Here is a table of a few characters and their unicode values
Character | unicode |
---|---|
c | \u0063 |
a | \u0061 |
t | \u0074 |
![]() |
\u306d |
![]() |
\u3053 |
In Java, the "\u" is an escape sequence which tells the compiler that the following characters have a special meaning, the unicode for some character.
The following two statements will display the same results: the word "cat"
Note: It is important to remember that Codecheck just helps you get your code to work. It does not submit it for grading. You must download and submit the report for grading in the Canvas Assignment area.
It is important that you name your class exactly as specified otherwise Codecheck will not be able to process your submission and you will get no credit.
If you use an IDE like Eclipse or Netbeans, do not include a package statement. Codecheck will not be able to process your submission and you will get no credit.
To test your draft, click on the draft link below. Copy and paste the code for Bluej into the textarea and click submit. If your code passes the test, Congratulations. If not, go back to BlueJ, make any necessary changes, and repeat the process.
See the Submission directions at the bottom of the page.
Follow a similar process for the final version.
Links for Codecheck:
1B
This is a picture of Taran
.
He is trying as hard as he can to grow, but all his parents will give him to eat is milk. In this assignment, you will give Taran some help.
At this URL you will find a zip file with the graphics files you need. Download it, unzip it, and then in Bluej, open it by clicking Project > Non Bluej. You could copy and paste all the code from Codecheck into Bluej, but this will save you some time. Just download the file and unzip it into your cs46a/homeworks/drafts/hw1
folder.
Complete the Baby class following these instructions
For the draft, create the picture and draw it. Don't translate or grow it until the final version.
When you are ready to work on the final, copy the Bluej project (hw1b_taran
) into the cs46a/homeworks/finals/hw1
folder. Open the project from Bluej and complete the assignment.
Links for Codecheck:
1C
In this problem you will complete a program to calculate how many days are left until Thanksgiving Day. Thanksgiving Day is on Nov 27, 2014. Use the Day class presented in the videos.
Here is the set up. You will do a similar thing for every homework problem
homeworks/drafts/hw1
folderNow you are ready to do the assignment
today
. You do that by using new Day(), with no data in the parentheses. That will create a Day object with today's date. You will get a different object if you run the program again tomorrow.For the draft: Create a Day object representing the current day and assign it to a variable named today. (Don't change the print statement)
When you are ready to work on the final, copy the Bluej project (hw1b_days
) into the cs46a/homeworks/finals/hw1
folder. Open the project from Bluej and complete the assignment.
Submission
When you are finished with your code, submit it in Codecheck one final time. Notice at the bottom left there is a "Download" button. Click that and a .signed.zip file will be downloaded. That is the file you need to upload into Canvas.
Be sure to upload the .signed.zip file produced by Codecheck not the .java file you wrote. Do not alter the downloaded file in anyway. The files are digitally signed and the graders will check that they have not been altered.
For both the draft and the final, you will upload 3 signed.zip files. Upload all three programs at one time
Warning: do not submit the final version as the draft. In order to be graded correctly, you must submit a program that does exactly what is specified for the draft - no more, no less.