logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Your program, named galaxy, will receive as input a series of “battalion deployments,” or placements of troops on a certain planet. A battalion deployment consists of the following information

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Galaxy Logic Overview

Your program, named galaxy, will receive as input a series of “battalion deployments,” or placements of troops on a certain planet. A battalion deployment consists of the following information:

 

Timestamp — the time that this deployment order is issued.

General ID — the general who is issuing the deployment order.

Planet ID — the planet which the troops are being deployed to.

Jedi or Sith — Whether the General issuing the deployment is a Jedi or Sith.

(Flavor note: in Star Wars, the Jedi are the good guys on the Light side of the Force, and the Sith are the bad guys on the Dark side of the Force. Click the link below for more info on the Force).

Force-sensitivity — the average Force-sensitivity of the troops being deployed.

Quantity — the number of troops being deployed.

 

As you read each battalion deployment from input, your program should see if the new battalion can be matched with a battalion previously deployed on the planet. If a match occurs, then the two battalions engage in warfare. A new battalion can be matched with a previously deployed battalion if:

 

Both deployments are for the same planet.

General ID does not matter; generals are allowed to switch sides of the Force: i.e. order conflicting battalion deployments.

The deployments were issued on different sides of the Force. That is, one deployment was a Jedi deployment and the other was a Sith deployment.

The Jedi Force-sensitivity is less than or equal to the Sith Force-sensitivity.

The Sith always instigate fights, and they only fight battalions with Force-sensitivity which they are confident that they can overcome.

This does not mean that a battle will not occur if a Jedi battalion is being deployed. When a Jedi battalion is deployed, they may be ambushed by a previously deployed Sith battalion.

 

If the new battalion is a Sith battalion, it will always choose to attack the least Force-sensitive Jedi battalion on the planet, given that there is a Jedi battalion with lesser Force-sensitivity. If the new battalion is a Jedi battalion, it will always be ambushed by the most Force-sensitive Sith battalion on

 

the planet, given that there is a Sith battalion with greater Force-sensitivity. In the event of a tie in Force-sensitivity, choose the battalion that was deployed first (came first in the input file).

 

When a battle occurs, the battalions trade troops one-for-one, regardless of their Force-sensitivity. That is to say that an equal number of troops from both battalions are eliminated, equal to the number of troops in the smaller battalion. If one of the battalions survives, it remains on the planet for future possible fights. For example, if a Sith battalion with 20 troops fights a Jedi battalion of 30 troops, the Sith battalion is eradicated and the Jedi battalion remains with 10 troops.

 

In the event that the newly deployed battalion survives, it is possible that a new fight will break out. If the new battalion is Sith, they will then look to attack another Jedi battalion. If the new battalion is Jedi, they may be attacked again after defeating the first Sith battalion. This happens until no more fights break out: that is, there are no pairs of Jedi and Sith battalions remaining on the planet such that the Sith Force-sensitivity is greater than or equal to the Jedi Force-sensitivity.

 

Input

Input will arrive from standard input (cin). There are two input formats, deployment list (DL) and pseudorandom (PR). The first four lines of input will always be in the following format, regardless of input format, which you may assume are correctly formatted:

 

COMMENT: <COMMENT>

MODE: <INPUT_MODE> NUM_GENERALS: <NUM_GENERALS> NUM_PLANETS: <NUM_PLANETS>

 

<COMMENT> is a string terminated by a newline, which should be ignored. (You should comment your test files to explain their purpose.)

<INPUT_MODE> will either be the string ”DL” or “PR”. DL indicates that the rest of input will be in the deployment list format, and PR indicates that the rest of input will be in pseudo-random format. Details for these input formats will be explained shortly.

<NUM_GENERALS> and <NUM_PLANETS>, respectively, will tell you how many generals and planets will exist.

 

(5/5)
Attachments:

Expert's Answer

364 Times Downloaded

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

364 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

538 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

774 Answers

Hire Me
expert
Husnain SaeedComputer science

757 Answers

Hire Me
expert
Atharva PatilComputer science

875 Answers

Hire Me

Get Free Quote!

303 Experts Online