У вас вопросы?
У нас ответы:) SamZan.net

Go to bottom of question

Работа добавлена на сайт samzan.net:

Поможем написать учебную работу

Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.

Предоплата всего

от 25%

Подписываем

договор

Выберите тип работы:

Скидка 25% при заказе до 28.12.2024

Take Assessment: Certification Exam Practical

Начало формы

Please answer the following question(s).

You have 180 minutes to take this assessment.
Please complete this assessment by Fri Dec 04 2009 13:16:15 GMT+0600.

1.

Go to bottom of question. 

SSD1v2.0 Certification Exam Practical

Crocodile War

Background

This exam part is based on a servlet-based simulation that models aquatic life forms. Review the following documentation of the simulation and workbench before continuing.

  •  Simulation Description
  •  Simulation Documentation
  •  The iCarnegie Servlet Workbench
  •  Working with iCarnegie Servlet Workbench and Simulation Files

Description

To complete this exam, extend the simulation to model the pattern of two warring tribes of crocodiles: the red tribe and the green tribe. Different colored images represent each tribe.  Crocodiles of one tribe will attack and kill a crocodile from the opposing tribe that is in the same cell.

The following screenshot shows the form to set up the initial configuration of the lake:

Figure 1 Initial configuration

The following screenshot shows what your browser may look like after a simulation of 10 time blocks:

Figure 2 Sample output after 10 time blocks

The source directory provides a complete implementation of class Crocodile. Class Crocodile models the common behavior of crocodiles. Class Crocodile is a subclass of class Animal. Class Crocodile contains default implementations of the methods liveALittle, getImage, and getSpecies. Create class WarCrocodile so that it is a subclass of Crocodile. It must override the methods liveALittle, getImage, and getSpecies to implement the appropriate behavior, to return the appropriate image, and to return the appropriate species, respectively.

To complete this exam part, create the entire class WarCrocodile.

Files

Download and extract the following.

  •  handout-files.zip — This archive contains the iCarnegie Servlet Workbench and simulation file structure (as is described in Working with iCarnegie Servlet Workbench and Simulation Files). In addition to the workbench and simulation files, this zip file contains the following.
    •  Directory work 
      •  This is the directory in which to work. Store your WarCrocodile.java in this directory.
    •  Directory content 
      •  This directory contains initialWorldWarCroc.html and the image files necessary for the simulation.

Tasks

This section presents all of the tasks necessary to complete the exam successfully and represents the authority for any clarifications regarding tasks.

  1.  First, run the iCarnegie Servlet Workbench as described in Working with iCarnegie Servlet Workbench and Simulation Files.
  2.  Then, create class WarCrocodile as a subclass of Crocodile. Save the file that implements class WarCrocodile in directory work.
  3.  Next, add the following attributes to class WarCrocodile.
    •  private static final String SPECIES = "WarCrocodile" — This is the name of the war crocodile.
    •  private static final int ENERGY_TO_LOOK_FOR_ENEMIES = 1 — This is the amount of energy spent to look for enemies.
    •  private static final int ENERGY_TO_ATTACK = 5 — This is the amount of energy spent to attack enemies.
    •  private String tribe — This is the tribe to which this crocodile belongs.
    •  public static final String RED_TRIBE_ID = "red" — This is a string that identifies members of the red tribe.
    •  public static final String GREEN_TRIBE_ID = "green" — This is a string that identifies members of the green tribe.
  4.  Then, add the following constructor to the class WarCrocodile.
    •  public WarCrocodile(int initialRow, int initialColumn, Simulation initialSimulation, String initialTribe) — This constructor initializes a war crocodile organism to start life at a specified location in the specified simulation. Because WarCrocodile is a subclass of class Crocodile, consult the constructor of Crocodile to  initialize WarCrocodile properly. Use the super keyword to invoke the constructor. Finally, set the value of instance variable tribe to the value of the initialTribe parameter. 

Compile class WarCrocodile and test your implementation of the constructor as described in Working with iCarnegie Servlet Workbench and Simulation Files.

  1.  Next, add the following method to the class WarCrocodile.
    •  public String getSpecies() — This returns the string specified by the constant SPECIES.
  2.  Then, complete the following method in class WarCrocodile.
    •  public String getTribe() — This returns the string specified by the instance variable tribe.
  3.  Next, override the following method in class WarCrocodile.
    •  public String getImage() — This method returns the name of a file that represents this crocodile based upon the direction the crocodile is facing and the tribe of the crocodile.  Hint: Call method getDirection of class Animal to get the direction that the crocodile is facing.  The following tables show the mapping between direction and the image returned:

getDirection value

Image String of the green tribe

RIGHT

/Crocodile-right.gif

LEFT

/Crocodile-left.gif

UP

/Crocodile-up.gif

DOWN

/Crocodile-down.gif

  •   

getDirection value

Image String of the red tribe

RIGHT

/RedCrocodile-right.gif

LEFT

/RedCrocodile-left.gif

UP 

/RedCrocodile-up.gif

DOWN 

/RedCrocodile-down.gif

  •   
  1.  Compile class WarCrocodile and test your implementation of method getImage.
  2.  Next, complete the following method in class WarCrocodile
    •  private boolean inMyTribe(WarCrocodile croc) — This method returns true if the WarCrocodile provided by parameter croc is in the same tribe as this WarCrocodile.  Otherwise, this method returns false.  Hint: Use the method equals of class String to compare the two Strings.

Compile class WarCrocodile and make sure your implementation of method inMyTribe is free of compiler errors.

  1.  Then, complete the following method in class WarCrocodile.
    •  private WarCrocodile lookForEnemy() — This method looks for other crocodiles in the current location and determines if one is an enemy. It will return the first enemy that is found or a null if no enemies are found. First, reduce the crocodile's energy by ENERGY_TO_LOOK_FOR_ENEMIES.  Find any other life forms that share the current cell using method getNeighbors of class Simulation. Then determine if any of these life forms are WarCrocodile objects.  If any war crocodile objects are found, use the method inMyTribe to determine if they are enemies.  If an enemy is found, return the enemy WarCrocodile object.  Otherwise, return null.

Compile class WarCrocodile and make sure your implementation of method lookForEnemies is free of compiler errors.

  1.  Then, complete the following method in class WarCrocodile.
    •  private void killEnemy(WarCrocodile enemy) — This method will consume the amount of energy necessary to attack another crocodile and then kill the WarCrocodile provided by parameter enemy.  First, reduce this crocodile's energy by ENERGY_TO_ATTACK, and kill the enemy by calling enemy.die.

Compile class WarCrocodile and make sure your implementation of method killEnemy is free of compiler errors.

  1.  Next, complete the following method in class WarCrocodile.
    •  private void attackEnemiesIfPossible() — If the WarCrocodile has an amount of energy that is greater than ENERGY_TO_LOOK_FOR_ENEMIES, call lookForEnemies.  If an enemy is found and the WarCrocodile has an amount of energy  greater than or equal to ENERGY_TO_ATTACK, kill the enemy using the method killEnemy. If no enemy is found, do nothing.

Compile class WarCrocodile and make sure your implementation of method attackEnemiesIfPossible is free of compiler errors.

  1.  Finally, override the following method in class WarCrocodile.

public void liveALittle() — If this crocodile is not dead, invoke attackEnemiesIfPossible, then invoke the method liveALittle of the super class.

Compile class WarCrocodile and test your implementation.

Submission

Submit only the following.

  •  WarCrocodile.java

Go to top of question. 

File to submit:

Go to top of assessment. 

© Copyright 2004 iCarnegie, Inc. All rights reserved.

Конец формы




1. Нормы об ответственности за правонарушения в информационной сфер
2. Лечение пароксизмальной формы фибрилляции предсердий- ПФФП-
3. Институт наблюдателей в избирательном процессе
4. Организация обработки информации на ЭВМ по формированию плана поставок готовой продукции
5. Тема. MTLB. Робота в командному вікні
6. О развитиималого и среднего предпринимательства в Российской Федерациидля предоставления им субсидий
7. Подобное наложение системного кризиса и кризиса государственности создало уникальную комбинацию проблем и
8. Лабораторная работа ’ 1 Определение поля температур в помещении При устройстве систем отопления и вентил.html
9. Международное частное прав
10. Тема 4- Управление работой оборудованием арматурного цеха
11. 18 относятся к поршневым насосам простого действия и применяются для перекачивания суспензий и химически аг
12. Махабхарата великая эпическая поэма Индии состоящая из 110000 шлок Кунти была женой царя Панду и матерью пят
13. тема- сущность тенденции принципы эволюция
14. 041 Мієлоцити 55 7
15. Статья 72 Изменение определенных сторонами условий трудового договора в ред
16. Реферат по курсу Административное право Вариант 27.html
17. собственную функцию modus operndi той или иной мозговой структуры определенный принцип или способ ее работы
18. 200г яйцо 3 шт
19. Точка опоры. Это человек на которого можно положиться.html
20. Тематическое планирование уроков литературного чтения по программе Л