Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Learning Objectives Review concepts covered in CSIS-1410. Work with a new codebase. Build algorithms to provide the specified functionality. Build programming facility working with two-dimensional

Learning Objectives

  • Review concepts covered in CSIS-1410.
  • Work with a new codebase.
  • Build algorithms to provide the specified functionality.
  • Build programming facility working with two-dimensional arrays.

Overview

In this assignment, you will simulate how a virus spreads through a crowd. You will review concepts covered in CSIS-1410, including doc comments, creating a GUI, and file I/O. However, you will be challenged to use a different codebase, namely the classes from algs4.jar. Building algorithms that provide the specified behavior can take some thought, but working through challenging tasks strengthens your programming facility.

Style Guide | Rubric: Many companies and organizations have style guides. So does CSIS-2410, where all code submissions need to follow this Style Guide. Many submissions in CSIS 2410 have a rubric. I encourage you to read it before starting the assignment. You can find more information about rubrics in the Orientation module under Get to Know Your 2420 Canvas Course.

Team Assignment: This assignment encourages you to collaborate and pair-program with a designated assignment partner. However, if you prefer to work solo, reach out to your instructor early on to opt-out. Working with a partner allows you to review 1410 concepts together and help each other build the required algorithms. It also facilitates extending your professional network by getting to know one of your classmates better. Please read the Guidelines for Team Projects to ensure a shared understanding of what it takes to be a good team partner.

  1. Instruction

    1. Start by creating a new Java project called A01_Grid, and add a package called a01simulator. Add a file called Simulation.java. Implement a simulation of how a virus spreads through a crowd based on the following requirements: Download Grid. java and add it to the project.
    2. This assignment allows only classes from algs4.jar and the packages java.lang and java.awt
    3. Use StdDraw to create the GUI. The window of the GUI should be 800 high. This ensures the simulation is big enough to be observed easily.
    4. The simulation should be shown in a rectangular grid with 70 rows and 100 columns. The grid fills approximately 80 to 90% of the width of the GUI window. It is surrounded by padding on the left, right, top, and bottom. In other words: the grid with the simulation should not touch the sides of the GUI window or any text.
    5. Each cell of the grid represents a cell that can have one of the following four states:
      • healthy
      • recovering (for a limited time after getting infected)
      • immune (for a limited time after recovering)
      • empty (A cell can be empty because there was no living cell from the beginning or because a cell died.)
      Each state needs to be represented in a different color where immune is a lighter or darker shade of the color representing healthy.
    6. The GUI shows a title.
    7. The GUI displays the following four settings that can be changed before the simulation is started. It is not necessary to update these settings during runtime. Instead, you can implement them as constant fields that can be changed before running the simulation.
      1. Population: the number of non-empty cells in the grid when the simulation starts. Given that the grid has 70 rows and 100 columns, this needs to be a number between 0 and 7000. If the population is less than 7000, random fields shoudl be selected as empty.
      2. Recovery rate: the number of cycles it takes to recover after having been exposed to the virus E.g., If a grid has a recovery rate of 3, a cell getting infected would change its state to recovering and remain in that state for three update cycles. A cell remains contagious while recovering, in this case, for three cycles.
      3. Immunity rate: the number of cycles a cell is immune after recovering If a cell gets infected, its state changes to recovering. Once it is recovered, its state changes for a limited time to immune. How long a cell remains in the immune state depends on the immunity rate. E.g., If the immunity rate is 2, that means that a newly recovered cell remains in the immune state for two cycles. Therefore, it cannot be infected again during that time regardless of its exposure to the virus.
      4. Death rate: the average percentage of cells that die after having been infected If the death rate is 0, no cell dies. If the death rate is 100, everyone who is infected dies. If the death rate is 3, a cell getting infected could recover or die. The chance of dying is 3 out of 100, and the chance to recover is 97 out of 100.
    8. The program allows to randomly select n cells to be infected. Being infected puts the cells in the 'recovering' state. Pro tip: Include a way to infect specific cells. This makes testing much easier.
    9. Update and display the grid in regular intervals. The longer the intervales, the slower the animation. Whether and how a cell is affected by surrounding cells depends on its state. Here are the rules:
      • If a cell is healthy, its state depends on the health of surrounding cells. It gets infected if any of its immediate neighbors (indicated with a circle) or a neighbor from an immediate neighbor (marked with a dot) is infected. If a cell gets infected, its state either changes to recovering or empty. The latter is the case if a cell dies.
      • If a cell is recovering, immune, or empty, it is not affected by surrounding cells. A recovering cell changes its state only based on the recovery rate. Once it has been recovering for the specified amount of cycles, it changes to immune. An immune cell changes its state only based on the immunity rate. Once it has been immune for the specified amount of cycles, it changes to healthy.
    10. Stop the simulation when all cells are healthy or empty (no recovering cells, no immune cells).
    11. Keep track of the new infections, total infections, and total death. Create a file called Update.txt before the simulation starts. Write a line to the file that includes the latest number of new infections, total infections, and total death in each update cycle. Format the information in straight columns to make the file easier to read. Example line: new infections: 94 total infections: 208 total deaths: 0
    12. Together as a team, answer the following team collaboration questions:
      • How often did you meet, and how long?
      • How many hours did you spend in total? Include the time team members worked on this assignment individually and together.
      • What was the most challenging part of the assignment?
      • How was the team experience? Were the partners responsive, lived up to their commitments, treated each other with respect, etc.?
      • What is the pebble distribution? If the pebble distribution is uneven, include an explanation of why. For more information on the pebble distribution, check out the Guidelines for Team Projects. can you give be brief explanation with the code thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions