Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSCI251  Advanced Programming

Spring 2022

Assignment 2 (Worth 14% )

Overview

This assignment is to be implemented using object oriented programming.  It involves implementing a simulation of an election campaign and the election in a country named Nosam.  The citizens, called Nosamians, are voting in an election for three political parties, from which a winner will emerge.  The political parties will campaign on five (5) issues that concern Nosamians. It is expected that the issues will affect the various electorates in the country differently and the political parties will also have dif- ferent stances on each of the issues. Give the political parties and electorates sensible names.

In addition to providing code, you need to submit a final report, which contains a UML-like class diagram reflecting the structure in your code, and text/tables/diagrams addressing the points below:

1. Describe qualitatively (i.e numerically), the five (5) different issues that you have chosen.

2. Describe the three (3) political parties and specify the range of stances on each issue.

3. Describe the characteristics of your electorates, and how the stance distribution for the electorates is modelled.

4. The winner for an electorate is the candidate for that electorate who obtains the most votes. You need to describe how the number of votes for each candidate is obtained.  There should be randomness in this process.  While the process does not need to be particularly complicated, there should be dependence on the relative stances of electorates, candidates and on candidate popularity.

5. Describe the characteristics of the candidates and the qualitative1  impact they have.

6. Describe the characteristics of the other people associated with the political parties and the qual- itative impact they have.

7. Describe the events you have chosen and how the event mechanisms qualitatively depend on the characteristics of the components described above.

General notes

These are some general rules about what you should and should not do.

1. Your assignment should be sensibly organised with the same kind of expectations in this area as assignment one, although you may reasonably have more files for this assignment.

2.  Other than the  initial  command  line  input,  the  program  should  run without  user input.  In particular this means there should not be pauses waiting for the user to press a key.

3. Your code must compile on Capa with the compilation instructions you provide in your submitted Makefile. It is assumed that you have written your code so that it complies with C++17 standard. Furthermore, you will benefit from adding the -Wall option to your compilation command in order to address any warning messages.  Please do not submit project, object or  .txt files.  You must submit only the source code files ( .cpp,  .hpp) necessary to generate an executable file, APE.

4. You must use classes, and should make use of encapsulation.

5. You must use inheritance. If you do not use inheritance you will lose few marks.

6. You can use polymorphism, if you consider and justify its appropriateness.

7. If you use operator overloading, it should be appropriate.

8. You can use your own data files to import names or similar information into your program.

9.  Output should only be to standard out or standard error.

1    A political episode

The nation Nosam is on edge ahead of the upcoming election campaign.  The leaders have presented their candidates and published manifestos detailing their plans for the country. You need to design and build a simulation of the campaign and subsequent election.

Your code should compile on Capa (i.e. it must be C++17 compliant) according to instructions you provide in a Makefile.

Once your program is compiled into the executable APE, it must run as follows:

./APE n m

where n is the number of electorates in the nation, and m is the number of campaigning days before the election. The value of n should be in the range 1 to 10 inclusive. The value of m should be in the range 1 to 30 inclusive.

On running, APE should report on each party (recall that there are three political parties). The report should include their stance values, the relevant details of their candidates, leader, and other significant figures.

APE should also report on the state of the nation by giving details on the electorates including the stance distribution. For example, in each electorate you could report the stance distribution for each of the five issues.

2    Components

You need to give consistent and appropriate definitions for a class hierarchy associated with the various components of the campaign and election.

2.1    Issues

You need to decide on five (5) issues of relevance (i.e.  concerns), for the nation.  These can be real- world national issues, such as global warming, real-world local matters, such as road infrastructure, or not-so-likely issues, such as the rights of pets.  For simplicity, we model a stance on an issue as being two–dimensional, with the dimensions being:

1. The significance of the issue.

2. The approach taken on the issue. You do not need to specify what the approach means. It is just a scale where similar values mean similar approaches and quite different values represent different approaches.

Each party and electorate will have different stances on each issue.  The leaders and candidates share the same stance with their parties.  Events may change stance values and you should model how the change happens.

2.2    Political parties and candidates

Each political party has the following officials:

1.  One leader, not themselves a candidate for an electorate.

2.  One candidate for each electorate.

3.  One centralised campaign managerial team.

Each political party has a range across each stance. You define this for each of your three political parties. Initial stance values should be randomly generated and lie somewhere in that range.

Both the leader and the candidates will have popularity and at least one other characteristic. You are at liberty to determine how those are relevant, but both popularity and the other characteristic(s) must have some impact.

2.3    Electorates

You need to determine appropriate components to represent the electorates. Each will have a political stance distribution rather than a specific stance.  It is up to you to decide how this works.  Try not to trivialise it to being a single stance as for the candidates and parties. The use of a statistical distribution will earn you additional marks.  You may recall that you played with discrete probability distribution in the Penalty shoot out” Lab 2 exercise.

2.4    Campaign days and events

Each day of the campaign involves the candidates and leaders attempting to convince the electorates to support them.

On every day of the campaign, for each electorate, there is a 40% chance of a local event:

1. Debate.

2.  Candidate-related event. You need two different types of these events.

3. Leader-related event. You need two different types of these events.

4. Issues-related event. You need two different types of these events.

Leaders, candidates, and the campaign managerial team will have some impact on the outcomes. As already indicated, events may change stances.

It is up to you to determine the likelihood of individual events, but they should be weighted towards less significant events. You should describe the events and their impact in your report.

Each campaign day APE should report the day, what has happened in each electorate,  and the significant impacts that have occurred.

2.5    Election day and wrapping up...

Immediately before election day, you should report on each party, including their stance values, the relevant details of their candidates and leaders.

You also need to report on the state of the nation, including details on the electorates; population and stance distribution.

For each candidate, you need to provide the breakdown of votes and identify the winner; the candidate with the most votes wins.

You then need to provide a national summary, showing the number of electorates won by each party. If a party has won more than 50% of the electorates, they will form a government, and you can report the party leader as the new leader for the country. If no party has won more than 50% of the electorates, APE should declare a hung parliament.

Notes on submission

Submission is via Moodle.

Your code must compile on Capa with the instructions you provide.

Please submit your source (i.e.   .cpp and  .hpp) files, Makefile, any data files used and report, in a zip file name studentID A2 .zip.   There should not be any directory structure within the zip file.