header

Simulation fundamentals

program goal

Use our custom-typed Agent object to simulate the success of various secret agents at maintaining their cover in various assingments. Use List objects for storing agents which mantained cover and those which didn't. Use iterators for displaying agent-related data and summaries of various simulations.

refactor agent

Refactor your agent to include a private member called stealthiness of type double and a boolean type called secretCoverUpheld.

create a country map

Create a Map whose keys are String objects and values are Double typed. The key should be the name of the country and the Double a number between 0 and 1 representing the general riskiness of the country assigned.

create a simulator method

Write a method that takes in an agent object and a country's risk rating and uses a trusty algorithm to determine if the agent's cover was exposed or not taking into account their stealthiness rating and the country's riskiness rating. The return type should be Agent and should be the same object that was passed in with its secretCoverUpheld member variable set properly.

simulate and report

Generate ten thousand Agent objects with random ratings for stealthiness. Randomly assign each to a country and extract the country's riskiness from the map. Send them into your simulation method and based on their outcome, store them in one of two lists: one for those who upheld their cover and those which didn't. Iterate over each of these lists and compute the min, max, and average stealthiness score for each group and display that data to the user in a nice format. If you have time, create a country-by-country report of how many agents were assigned and how many's cover was blown.

arrow_upward up


Page created in 2019 by Eric Xander Darsow. Original content can be freely reproduced without any permission or attribution according to the site's content use agreement. Any content accessed by links to external sites or content with specific rights notices is governed by its respective use agreements.