The Mind Of Sauron
From Huben's Wiki
(Created page with "Project Simulate Sauron We are going to write a sizable class, but it will not need to compile. The goal is to get the variable and method declarations right. When writing var...") |
|||
Line 1: | Line 1: | ||
− | + | [[Image:Eye of sauron.jpg]] | |
− | We are going to write a sizable class, | + | We are going to write a sizable class, compile it, and run it. The goal is to get the variable and method declarations right and the arguments and returns right. |
When writing variable declarations, you need to consider: | When writing variable declarations, you need to consider: | ||
Line 18: | Line 18: | ||
* http://en.wikipedia.org/wiki/Sauron | * http://en.wikipedia.org/wiki/Sauron | ||
* Be creative! | * Be creative! | ||
− | * You may assist each other, or | + | * You may assist each other, or work in pairs. Be sure to put a comment at the top saying who takes credit for the code and who assisted you. |
Write a class named Sauron with the following fields and methods: | Write a class named Sauron with the following fields and methods: | ||
− | * The number of Orcs in his army. ( | + | * Fields: |
− | * | + | ** The number of Orcs in his army. (Make a guess.) |
− | * The | + | ** The number of Uruk-Hais in his army. (Make a guess.) |
− | * | + | ** How many Hobbits it takes to feed an Orc one day (you can feed an Orc five days on a Hobbit.) |
− | * | + | ** How many Hobbits it takes to feed an Uruk-Hai one day (you can feed an Uruk-Hai three days on a Hobbit.) |
− | * An array of | + | ** An array of three words of a spell. |
− | * A method printing an evil cackle. | + | * Methods: |
− | * A method dispatching a number of ringwraiths to a location name. | + | ** A method printing an evil cackle. |
+ | ** A method dispatching a number of ringwraiths to a location name. (It doesn't have to do anything, just have the arguments.) | ||
+ | ** A method for chanting a spell. Its argument is an array of words, three in number. It should call another method for each word that will print the word twice. | ||
+ | ** A method for calculating the number of Hobbits needed as food by a number of Orcs and a number of Uruk-Hais over some number of days. | ||
+ | ** A main() method. | ||
+ | *** Start with a cackle! | ||
+ | *** Chant the spell in your field, then chant another spell you make up. | ||
+ | *** Send 9 ringwraiths to The Shire. | ||
+ | *** Print the number of Hobbits needed as food for your army every week. | ||
+ | *** Print the number of Hobbits needed as food for your army every week if you double the number of Orcs. | ||
+ | |||
+ | When you are done, put the code and the results from running it into a document, then print it for me to grade. You can also show me what you've done at the computer any time. Do not get stuck: you should be able to get this done today if you persevere. If you can't then finish it for homework. | ||
+ | |||
+ | <!-- | ||
+ | What we should have learned: | ||
+ | * How to translate an English description into a field or method. | ||
+ | * You don't need to know the context to program something. | ||
+ | * How to follow instructions closely and completely. | ||
+ | * How to use a method more than once with different arguments. | ||
+ | * How to make a method and use it more than once rather than duplicate code. | ||
+ | * How to make and use arrays. | ||
+ | * How to initialize Strings and arrays of Strings. | ||
+ | * Returned values must match the return type. | ||
+ | * The difference between int and double, especially for division. | ||
+ | * How to pick meaningful names for methods and variables (fields and local variables.) | ||
+ | * The meaning of static, public and private can still be a mystery. | ||
+ | * Pitfall: using the same name for a field and an argument or local variable. Don't do it. | ||
+ | * We can write a large, awesome program that does real stuff! | ||
+ | --> | ||
+ | Rubric (partial credit is available for all items): | ||
+ | {| border="1" | ||
+ | |- | ||
+ | | Points | ||
+ | | Description | ||
+ | |- | ||
+ | | 30 | ||
+ | | Following instructions closely and completely. | ||
+ | |- | ||
+ | | 20 | ||
+ | | Translation of an English description into a field or method. | ||
+ | |- | ||
+ | | 10 | ||
+ | | Using a method more than once with different arguments rather than duplicating code. | ||
+ | |- | ||
+ | | 10 | ||
+ | | Making and using arrays. | ||
+ | |- | ||
+ | | 10 | ||
+ | | Initializing Strings and arrays of Strings. | ||
+ | |- | ||
+ | | 10 | ||
+ | | Returned values must match the return type. | ||
+ | |- | ||
+ | | 10 | ||
+ | | The difference between int and double, especially for division. | ||
+ | |- | ||
+ | | 10 | ||
+ | | Meaningful names for methods and variables | ||
+ | |- | ||
+ | |} |