Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

Learning Outcomes:

By completing this assignment, you will gain skills relating to Strings and text files Writing your own classes Testing code Using complex data structures (i.e., sets and dictionaries)

In this assignment you will create a complete program that uses classes to store, search, sort, remove, and filter country data. The two major tasks are outlined below.

1. Implement a class Country Instance Variables:

i. Name: string

ii. Population: integer

iii. Area: float

iv. Continent: string Methods:

i. constructor

ii. Getter Methods: getName, getPopulation, getArea, getContinent,

iii. getPopDensity: This calculates and returns the population density for the country. Pd is the population divided by the area.

iv. Setter Methods: setPopulation

v. def __repr__(self):generate a string representation for the class Name in Continent

e.g China in Asia In addition add a method save that writes the appointment to file object (not file name) in the specified format : Name|Continent|Population|PopulationDensity

For example China|Asia|1000000|4.56 class Country :

def __init__(self, name, pop, area, continent) :

def __repr__(self):

def setPopulation(self, pop):

def getName(self) :

def getArea(self) :

def getPopulation(self) :

def getContinent(self):

def getPopDensity(self) :

def save(self, outobject) : Test all your classes and methods before moving to the next section. Feel free to create other

helper methods if necessary. Write a test file that will also be submitted with this assignment

(test.py)

2. Implement a class called CountryCatalogue that is a set or dictionary or lists of countries.

This class has two instance variable catalogue and cDictionary

This class will have the following methods. Constructor: this method will open the specified file and then first create the

cDictionary and then create countries and add them to the cSet.

Major Steps

1. Fill the Dictionary: open the continent.txt file and fill the cDictionary.

The key is the country name, while the continent is the value.

2. Fill the Catalogue: Open the file (the file name is passed into the

constructor). Then read each line of the file and from that create a

country and add it catalogue.

A sample data file has been included data.txt (Note that both files have headers) addCountry: Give the user the option to add a new country to the set.

Using user input the user must specify the name, population, area and continent. If the country they entered already exists, let them know they can't add a country already in the catalogue and keep on prompting for input until a unique name has been entered. In addition to adding the newly created country to the catalogue, make sure you add the continent to the cDictionary. Include a confirmation message to let the user know whether the operation was successful or not. saveCountryCatalogue: allow the user to save all the countries to a file. This method MUST call the save method for the Country class. Before saving the catalogue sort the countries alphabetically by name. Include a confirmation message to let the user know that it was saved to the specified file. deleteCountry: allows the user to enter a specific countryName, if this country exists then it should be deleted from the catalogue. Include a confirmation message to let the user know whether or not it was deleted. findCountry: allows the user to enter a specific countryName, if this country exists then print all of the country's information to the output screen. If the country does not exist send a message as well. filterCountriesByContinent: allow the user to enter a specific continent (assume valid continent), print to the screen all the countries (just their names) in the catalogue that are in that continent.

printCountryCatalogue: print the whole catalogue to the screen, using the default print for the Country Class setPopulationOfASelectedCountry: Ask the user for a country name and new population and then set the population of the country (if it is in the catalogue) to the value. Print the new population density for that country to the screen. findCountryWithLargestPop: find and display the name of the country with the largest population to the screen findCountryWithSmallestArea: find and display the name of the country with the smallest area to the screen.

filterCountriesByPopDensity: ask the user to enter the lower bound and upper bound for a population density range and then find all countries that have a population density that falls within the range. Assume valid input of integers.

findMostPopulousContinent: find and display the name of the continent with the most number of people living in it. Also display the number of people living in the continent.

class CountryCatalogue:

def __init__(self, filename):

def filterCountriesByContinent(self):

def printCountryCatalogue(self):

def findCountry(self):

def deleteCountry(self):

def addCountry(self):

def setPopulationOfASelectedCountry(self):

def saveCountryCatalogue(self, filename):

def findCountryWithLargestPop(self):

def findCountryWithSmallestArea(self):

def findMostPopulousContinent(self):

def filterCountriesByPopDensity(self): Test your countryCatalogueClass to make sure all functionality is working. Save your test code in test.py

Use the main.py file provided as the interface to your program. The TA will use a similar main.py to grade your assignment. DO NOT EDIT THIS FILE AT ALL

For output to both the console and file you do not need to format numbers to include commas. (e.g 1000 does NOT need to be written as 1,000)

You may assume all the data is correct and there are no errors relating to the data file (so don't worry about Exceptions or validating input except where otherwise noted for this assignment). Non-functional Specifications:

1. Include brief comments in your code identifying yourself, describing the program, and describing key portions of the code.

2. Assignments are to be done individually and must be your own work. Software may be used to detect cheating.

3. Use Python coding conventions and good programming techniques, for example:

i. Meaningful variable names

ii. Conventions for naming variables and constants

iii. Use of constants where appropriate

iv. Readability: indentation, white space, consistency Submit two files one file that includes both classes the filename should be countryGalore.py. Also include a test file named test.py that shows how you tested your classes.

Make sure you attach your python files to your assignment; DO NOT put the code inline in the textbox.

Make sure that you develop your code with Python 3.5 as the interpreter. TAs will not endeavor to fix

code that uses the Python 2.7 or 2.10 conventions.

What You Will Be Marked On:

1. Functional specifications: Does the program behave according to specifications? Does it run with the main program provided? Are your classes created properly? Are you using appropriate data structures? Is the output according to specifications?

2. Non-functional specifications: as described above

3. Assignment submission: via OWL assignment submission.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92063852
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question discuss the advantages and disadvantages of

Question: Discuss the advantages and disadvantages of Incident Response testing. When is each type of testing appropriate? Are there situations that preclude the use of a particular type of testing? Requirement: I recomm ...

Question advanced microprocessors amp labdirect addressing

Question: Advanced Microprocessors & Lab Direct Addressing and Initializing the Stack Directions: Please answer BOTH of the questions. About 50-75 words per question. Plagiarism will be disputed, so please be 100% origin ...

Scenario 1 19500 ascii characters are transmitted over a 3

Scenario 1: 19,500 ASCII characters are transmitted over a 3 Mbps circuit. The protocol uses 8-bits to encode each ASCII character, and adds an additional parity bit to help detect errors. Calculate the transmission effi ...

1population parametric mean 53501standard deviation

1) Population (parametric) mean= 53.501 Standard deviation = 1.79208 Imagine that 5 individuals are sampled at random from this population. Calculate the probability that the average calculated will be less than the valu ...

Question have you received emails like thesewhat actions if

Question : Have you received emails like these? What actions, if any, have you taken to limit the permissions of the sender? Why or why not? In your chapter reading, you learned about the CAN-SPAM law From your perspecti ...

Understanding the digital revolution assignment - parchment

Understanding the Digital Revolution Assignment - Parchment Purgatory Overview - For this assignment, you will use skills acquired through practical laboratory exercises to automate a business process, and to visualize t ...

What is 4g and its benefits how fast is your internet

What is 4G and its benefits. How fast is your Internet service supposed to be for stationary users?

Question need to discuss on issues and security

Question: Need to discuss on issues and security vulnerabilities caused by using 4 digit pin while accessing Banking. 1) Abstract 2) Acknowledgement 3) List of Abbreviations 4) Table of contents 5) List of tables 6) List ...

Draw supply and demand curve to illustrate the following

Draw supply and demand curve to illustrate the following sequences of events. Show changes in one graph. Assume upward sloping for supply curves and downward sloping for demand curves 1. In year 1, the rental apartment m ...

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As