讲解:Internet、Java,c++、Python、UML diagramsSPSS|Prolo

Homework Assignment 3Late homework assignments will not be accepted, unless you have a valid written excuse (medical, etc.). You must dothis assignment alone. No team work or talking with your friends will be accepted. No copying from the Internet.Cheating means zero.Create a new Eclipse workspace named Assignment3_1234567890 on the desktop of your computer (replace1234567890 with your student ID number). For each question below, create a new project in that workspace. Calleach project by its question number: Question1, Question2, etc. Answer all the questions below. At the end ofthe assignment, create a ZIP archive of the whole workspace folder. The resulting ZIP file must be calledAssignment3_1234567890.zip (replace 1234567890 with your student ID number). Upload the ZIP file oniSpace.Here are a few extra instructions: Do not forget to write tests for all the code of all the classes. Give meaningful names to your variables so we can easily know what each variable is used for in your program. Put comments in your code (in English!) to explain WHAT your code is doing and also to explain HOW yourprogram is doing it. Make sure all your code is properly indented (formatted). Your code must be beautiful to read.Failure to follow these instructions will result in you losing points.Question 1Create a class Mammal with the following UML diagrams:+---------------------------------+| Mammal |+---------------------------------+| - name: String |+---------------------------------+| + Mammal(String name) || + getName(): String || + isCookable(): boolean || + testMammal(): void |+---------------------------------+The isCookable method of the Mammal class returns a boolean indicating whether the mammal can be cooked ornot: some mammals can be cooked and some mammals cannot be cooked so for safety reasons the isCookablemethod just prints a message Do not cook this! and returns false (because the isCookable method mustreturn a boolean).Add a class Human to your program. A human is a mammal. The constructor for the Human class takes no argument. 代做Internet、代写Java,c++程序语言、PythAllhumans are named Alice and humans cannot be cooked (the isCookable method must not print any messagethough, it simply returns false).Add a class Rabbit to your program. A rabbit is a mammal. The Rabbit class has a private instance variable weightof type double that describes the weight of the rabbit, and a getWeight method. The constructor for the Rabbitclass takes the rabbit’s name and the rabbit’s weight as arguments. A rabbit can be cooked.Add a class EuropeanRabbit to your program. European rabbit is a species of rabbit. The EuropeanRabbit classhas two constructors: the first constructor takes the European rabbit’s name and the European rabbit’s weight asarguments; the second constructor only takes the European rabbit’s name as argument and always uses 2.0 as theEuropean rabbit’s weight. The second constructor must use the first constructor.Add a class LapinSautéChasseur to your program. Lapin sauté chasseur is a kind of European rabbit. Theconstructor for the LapinSautéChasseur class takes no argument. Lapin sauté chasseur is always namedDelicious and has a weight of 0.5.Add a class FrankTheRabbit to your program. Frank The Rabbit is a kind of rabbit. The constructor for theFrankTheRabbit class takes no argument. Frank The Rabbit is always named Frank, has a weight of 100.0, andcannot be cooked.Add a class Start to your program to test all your classes.Question 2Add a class CastIronPot to your program with the following UML diagram:+---------------------------------+| CastIronPot |+---------------------------------+| - rabbit: Rabbit |+---------------------------------+| + CastIronPot(Rabbit rabbit) || + getRabbit(): Rabbit || + testCastIronPot(): void |+---------------------------------+In the testCastIronPot method, create a lapin sauté chasseur called lsc1, then create a cast iron pot with thislapin sauté chasseur in it. Then get the lapin sauté chasseur from the cast iron pot and store it into a local variable calledlsc2 of type LapinSautéChasseur. Use the == operator to check that lsc1 and lsc2 are the same lapin sautéchasseur.转自:http://www.3daixie.com/contents/11/3444.html

你可能感兴趣的:(讲解:Internet、Java,c++、Python、UML diagramsSPSS|Prolo)