Create a complete program that uses classes to store data

Assignment Help Computer Engineering
Reference no: EM131309225

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.

Reference no: EM131309225

Questions Cloud

Find online reviews for a product you would like to buy : Find online reviews for a product you would like to buy. Which of the reviews infl uences you most? What about these reviews do you find persuasive?
Secure encrypted communications : Transmitting personal and business data and information over secure communication channels is critical. In some cases it is required, especially when personally identifiable information is being transmitted. Credit card numbers, Social Security Nu..
Write letter to business owner or companys customer service : Think about a negative customer service experience you had recently. Write a letter to the business owner or the company's customer service department explaining what happened.
Present an analysis of a change effort : After studying the various OD interventions and theories, present an analysis of a change effort that you experienced (that succeeded). Identify one presented theory or intervention that most closely relates to why the change effort succeeded. The..
Create a complete program that uses classes to store data : CS1026: Assignment- 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.
Discuss that statement and its relevance to economy today : The unemployment is part of the natural rate and need not concern policy makers. Discuss that statement and its relevance to the economy today.
Develop a simple but attractive webpage using css : CE206 - Assignment 1. OBJECTIVE: To develop a simple but attractive webpage using CSS and following HCI criteria. Read the design brief to get a good understanding of the requirements of the client (Head of School). Search the web for webpages that ..
Discuss starbucks need for a new strategy : Discuss Starbucks' need for a new strategy in the late 2000s. Based on the analysis, what are the strengths and weaknesses of Starbuck's current strategy?
New product and strengthen the product portfolio : Selected Organizational Goal: Offering the world a portfolio of drinks brands that anticipate and satisfy people's desires and needs Team: Research and development -New product and strengthen the product portfolio

Reviews

Write a Review

Computer Engineering Questions & Answers

  Make a public static method named comparescores

Write down a public static method named compareScores that takes two doubles as its arguments and returns the integer value of -1 if the first argument is less than the second, 0 if the first argument is the same as the second, and +1 if the first..

  Program to generate random numbers

The purpose of this program is to generate random numbers, report total number created, how many were 15, 16, or 17 and report this information to the user. Create an array of 1000 integers in your main function

  Questioninline internal procedures deposit and withdraw

questioninline internal procedures deposit and withdraw. that is replace references to them by the bodies of

  Questionafter front-office network at xyz corp is set up an

questionafter front-office network at xyz corp. is set up an accountant realizes that if loading dock connected to the

  What might have happened if the bug had not been caught

My first programming job in 1977 was to convert a set of application systems from one version of COBOL to another version of COBOL for the government of Prince Edward Island. What might have happened if this bug hadn't been caught and all gas tax r..

  Technology to be used identify the selected technology the

the course builds upon the first two questions that was done prior to this. in this research paper you will identify

  What is the final step in determining observability

What is the final step in determining observability if the observability matrix is a square matrix?

  Give process that occurs between a client and web server

define the process that occurs between a client and Web server by describing the functionality of the OSI reference model. Diagram the interaction between the client and the server and illustrate the data flow.

  Write a class named card which can be used to represent a

write a class named card which can be used to represent a card from a deck of cards. the class should be able to stores

  Investigate applications-laplacian pyramid blending

In this project, you will investigate two applications: Laplacian pyramid blending and hybrid images. You can use the former to make smooth transitions between arbitrary images, such as the fish sandwich depicted in Figure

  Find the average number of miles per gallon

design a class named Vehicle that acts as a superclass of vehicle types. The Vehicle class contains private variable fo rthe number of wheels and the average number of miles per gallon.

  Create a document which defines and describes it

Create a document which defines and describes IT. You may use any resource; however, be sure to cite any resources you use

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd