Many years ago politics was straight forward. MPs held beliefs and their actions were guided by these beliefs. In modern society however politicians have beliefs but are more than happy to change them whenever it is convenient to do so. This new type of politics needs sophisticated software to model it.

There are four different types of politician; Conservative MPs, Liberal Democrat MPs, Labour MPs and Green Party MPs. The “firmly held” beliefs of these politicians are very different.

Conservative MPs believe that “they know best”. Liberal Democrat MPs believe that “the public are daft”. Labour MPs believe that “everybody should have a job”. Green Party MPs believe that “recycling is fun”.

The politicians also differ in where they live. Conservative MPs live in “big detached houses”. Liberal Democrat MPs live in “cloud cuckoo land”. Labour MPs live in “modest houses”. Green Party MPs live “in trees”

Using the Strategy pattern develop the Java code to model the MPs and their behaviour.

You should develop a menu driven system that allows the user create MP objects of any type and to dynamically change the behaviour of what the MP believes and where they live. When the user creates an object they will enter the MPs first name and second name using the menu system. All MPs will have their default behaviour set when the object is created. The menu should also allow the user to print the details of each of the MPs i.e. what they believe and where they live.

The menu system will allow the user to create objects, view objects and change the behaviour of objects.

Menu System

  • Create Objects
    • Create a Conservative MP
    • Create a Liberal Democrat MP
    • Create a Labour MP
    • Create a Green Party MP
  • Display Objects
    • Display the details of a Conservative MP selected by the user
    • Display the details of a Liberal Democrat MP selected by the user
    • Display the details of a Labour MP selected by the user
    • Display the details of a Green Party MP selected by the user
  • Change Behaviour
    • Select any Conservative MP and change any of its behaviour
    • Select any Liberal Democrat MP and change any of its behaviour
    • Select any Labour MP and change any of its behaviour
    • Select any Green Party MP and change any of its behaviour
  • Exit

Your system should serialize the data when the user exits. When the system is started up you should load the serialized data.

In addition to your program you should provide a comprehensive JUnit test suite. This should test all of the methods on your main MP class and any subclasses of the MP class. You do not need to provide JUnit tests for your menu system nor for any of the behaviour classes which implement the behaviour interfaces

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.