Build a utility app that helps customers figure out the cost

Assignment Help Python Programming
Reference no: EM13945110

Coding Project

Part 1

Bill's Budget Adventures, a tourist company, has asked you (an indie developer) to build a utility app that helps their customers figure out the cost of items in the countries they visit on a trip. Bill thinks the app should run on any mobile phone, laptop, or desktop computer, since his customers come from all over the world. But, he is happy for you to create a prototype of the app that runs on desktop only. He needs the app to always use the latest information about exchange rates for each of the tourist destinations.

Coding Requirements

In this part of the project, you are required to construct a Python 3 project that satisfies the following:

? Use the provided web_utility.py module - it allows you to read the HTML content of a Web page, given a valid URL string (note: this module is available under the Assessment link)
? Create a module called currency that contains the following functions:
- convert()
- get_details()

? Create a module called trip that contains the following three classes:
- Error
- Country
- Details

Currency Module Details

convert(amount, home_currency_code, location_currency_code)
? The first parameter is an amount of money, and the other parameters are currency codes.
? Use the provided web_utility module to load data from the Google Finance currency converter Web page (see below) to convert the given amount of money in the home currency to the amount in the location currency. Example:
- calling currency.convert(1, 'AUD', 'JPY') returns 86.2379 (so $1 Australian dollars converts to about $86.24 Japanese yen).
- Calling currency.convert(86.2379, 'JPY', 'AUD') returns 1.0004.
? If this function is used incorrectly (e.g. trying to convert from AUD to AUD) or some other problem occurs (e.g. can't read data from the Web page) then the value returned must be - 1.
? To implement this function, apply your knowledge of text processing to extract the necessary monetary information from the Web page results.

Here is an example of using web_utility to convert $1 from AUD to JPY:

url_string = "https://www.google.com/finance/converter?a=1&from=AUD&to=JPY"

result = web_utility.load_page(url_string) print(result[result.index('result'):])

Here is the output (string) for this code:

'result>1 AUD = <span class=bld>85.9474 JPY</span>\n<input type=submit value="Convert">\n</div>\n<input type=hidden name=meta value=ei&#61;8mb_VZH9GouO0ATpnIdw>\n</form>\n</body>\n</div>\n</html>\n'

Here is an example of using web_utility to convert $1 from JPY to AUD:

url_string = "https://www.google.com/finance/converter?a=85.9432&from=JPY&to=AUD" result = web_utility.load_page(url_string) print(result[result.index('result'):])

Here is the output (string) for this code:

'result>85.9432 JPY = <span class=bld>0.9969 AUD</span>\n<input type=submit

value="Convert">\n</div>\n<input type=hidden name=meta

value=ei&#61;82b_VfClA8aP0gS38LKoAQ>\n</form>\n</body>\n</div>\n</html>\n'

get_details(country_name)

? The parameter is the name of a country as a string

? Use the provided text file called currency_details.txt (also available on LearnJCU), which contains a list of all country names, currency codes, and currency symbols

- Example, Japan's entry is Japan,JPY,¥

? Make your function look for a matching country name in the text file:
- If found, return a tuple containing the matching country name, the currency code, and the currency symbol.
- Otherwise return an empty tuple.

Trip Module Details

Error
? In the trip module, create an Error class derived from the built-in Exception class.
? Use it to raise exceptions when your own code generates a runtime error.
? Note that the exceptions you generate must have appropriate descriptions for the
Exception.value field.

Country
? This class is used to represent the details about a single country. Define the fields:
- name
- currency code
- currency symbol
? Create an initialiser method to define these three values for a new Country object.
? Create a method (you decide on a good name) that takes an amount of money and returns a formatted string that has the currency symbol prepended to it followed by the amount of money rounded to the nearest cent (e.g. for the object Country('Germany', 'EUR', '€') this method would generate the string '€100' given the amount 100).
? Create an overloaded version of the special str function that returns a string
containing the country details (e.g. the object Country('Germany', 'EUR', '€') would generate the string 'Germany EUR €').

Details

? This class is used to record the sequence of countries visited during a trip. Define the field:
- locations (you are allowed to implement this using a list or dictionary) used to store the trip details.
? Create an initialiser method to define the locations field.
? Create the method add(country_name, start_date, end_date).
- All three parameters are expected to be text.
- A date string conforms to this format: YYYY/MM/DD
- If the start_date is after the end_date then add() should generate an exception.
- If the start_date was already used in a previous add() then it generates an exception.
- Otherwise, add() inserts the new details in locations.
? Create the method current_country(date_string).
- A date string conforms to this format: YYYY/MM/DD
- If the date string is within the start date and end date for a particular trip location then the function should return the name of the country for that part of the trip.
- Otherwise the function generates an exception.
? Create the method is_empty()
- This method returns a value that indicates if locations is empty or not.

Coding Testing

Write test code in your currency and trip modules. Do this by making your modules detect if they are being executed or being imported. See: https://docs.python.org/3.4/library/ main .html

Write code that produces output similar to the following:

invalid conversion 1.00 AUD->AUD -1.00
invalid conversion 1.00 JPY->ABC -1.00
invalid conversion 1.00 ABC->USD -1.00
valid conversion 10.95 AUD->JPY 943.18
valid conversion reverse 943.18 JPY->AUD 10.94
valid conversion 10.95 AUD->BGN 13.62
valid conversion reverse 13.62 BGN->AUD 10.95
valid conversion 200.15 BGN->JPY 13859.49
valid conversion reverse 13859.49 JPY->BGN 199.58
valid conversion 100.00 JPY->USD 0.83
valid conversion reverse 0.83 USD->JPY 99.45
valid conversion 19.99 USD->BGN 34.58
valid conversion reverse 34.58 BGN->USD 19.99
valid conversion 19.99 USD->AUD 27.80
valid conversion reverse 27.80 AUD->USD 19.98

invalid details Unknown () invalid details Japanese () invalid details ()
valid details Australia ('Australia', 'AUD', '

) valid details Japan ('Japan', 'JPY', '¥') valid details Hong Kong ('Hong Kong', 'HKD', '

)

Project Documentation - Code Review and Critique

Use the provided template (located under the Assessment link) to create a document that discusses your choices and processes used in creating your source code. The document should be 1-2 pages long and describe in your own words the process you followed as you developed your coding solutions. We are interested in how you developed your code - starting with your throwaway prototypes and ending with your completed modules. Use the correct terminology for the various aspects you discuss in your outline.

The documentation is used to demonstrate your knowledge of coding and your application of problem solving strategies introduced in this subject, including code prototyping, top-down design, object-oriented design, refactoring, and incremental development.

The document should consist of the following sections:
? Review of currency module
? Review of trip module
- Country class
- Details class

Part 2

Bill from Bill's Budget Adventures had a chance to look over your prototype. He is very pleased and excited about the app! He is eager for you to create a GUI prototype next.

Bill's business partner Terry from Terry's Terrific Tours pointed out that when a tourist is overseas they might need to use the app in more ways that Bill thinks. For example, what if a tourist needs to know the cost of something in one of the other trip countries? Or what happens if the tourist is in a remote location without regular internet access?

GUI and behavioural requirements of the utility app

You are asked to use currency and trip modules from Part 1 to create a GUI utility app for easy monetary conversion between the currencies of a specified home country and a currently selected country on the trip. You must create a Kivy program using a PyCharm Python project. When the app starts it should look similar to this:

607_GUI.png

The GUI contains eight (8) widgets:
1. A Label that displays the current trip location
2. A Spinner whose values come from the names of trip countries but is initially blank
3. A TextInput used for entering monetary values for the current trip country
4. A Label that displays the name of the home country
5. A TextInput used for entering monetary values for the home country
6. A Label that displays the current date in year/month/day format
7. A Label that displays a status message for the app
8. A Button used to update the currency rates to use based on the home country and selected trip country

Notice that the TextInput widgets are initially disabled. If the user clicks on the Button then currency.convert is used to determine the conversion rate from the home country to the selected trip country and the conversion rate from the selected trip country to the home country (i.e. the utility app stores two conversion rates). When the conversion rates are successfully updated the status Label informs the user of the update time:

Things to note:

? If the Button is pressed and no Spinner selection has been made yet, then the current date determines the current trip location which sets the selected country name for the Spinner and updates the conversion rates.
? Changing the Spinner value does not update the conversion rates, so the user must select a country name from the Spinner and then click the Button to update the rates
? If a conversion rate update fails then the TextInput widgets should be disabled (enable them again when the next conversion rate update succeeds)

When the user enters a monetary value into a TextInput and hits ENTER the appropriate conversion rate is used to set the text of the other TextInput with the converted amount:

216_GUI1.png

Things to note:
? The updated TextInput shows the converted amount as a float with 3 significant digits
? The status Label is cleared

Other Requirements
? In a Kv language file called "gui.kv" define the GUI layout for your Kivy app
- The GUI must contain all of the required Widgets as defined above
- You are free to choose your own layout structure, colour scheme, text fonts, and font sizes as long as you justify your choices in your code review

? In a Python source code file called "app.py" define a derived Kivy App class with the following methods:
- It has an init method capable of initialising a trip details field
- It has a build method that sets the window title appropriately, sets the window size to 350 x 700, and defines the root widget appropriately
- It contains "callback methods" for handling various aspects of app behaviour as defined above

? When initialising your derived App class, use ‘helper methods' to load trip details from a text file called "config.txt" based on the following data protocol:

2059_GUI2.png

- The first line of the config file contains a single item - the name of the home country
- The remaining lines of the config file consist of three comma-separated items - the trip country, the start date, and the end date
? The status Label should be used to inform the user of the following three (3) outcomes:
- The config file is loaded successfully
- The config file could not be loaded (e.g. the file was not found)
- The config file loaded but it contains invalid trip details

Project Documentation - Code Review and Discussion

Imagine that you are invited to present your Kivy program in a formal code review to a local software engineering company. You are expected to present and defend your coding decisions.

Use the provided template (located under the Assessment link on LearnJCU) to write your code review on the choices and processes you used to create your source code. The document should be 1-2 pages long and describe in your own words the process you followed as you developed your coding solutions. We are interested in how you developed your code - starting with any throwaway prototypes and ending with your completed Kivy program. Use the correct terminology for the various aspects you discuss such as object-oriented design, helper methods, callback methods, MVC, observer pattern, refactoring, and incremental development.

The code review should consist of the following sections:
? Review of "gui.kv"
? Review of "app.py"

Attachment:- Assignment.rar

Reference no: EM13945110

Questions Cloud

Return on your equity investments : Leslie's Unique Clothing Stores offers a common stock that pays an annual dividend of $2.90 a share. The company has promised to maintain a constant dividend. How much are you willing to pay for one share of this stock if you want to earn a 11.70 per..
What circumstances would duration equal maturity : We have the Goncalves par bond paying a coupon rate of 8% and having a maturity of 20 years. If the coupon rate of Goncalves were to alter to 4%, what would the new duration be? What is the meaning of duration? Under what circumstances would duration..
Compute the predetermined overhead rate for the year : Determine the amount of overhead applied to production during the year. Compute the predetermined overhead rate for the year.
What range of frame sizes does stop-and-wait give efficiency : A channel has a bit rate of 4 kbps and a propagation delay of 20 msec. For what range of frame sizes does stop-and-wait give an efficiency of at least 50 percent?
Build a utility app that helps customers figure out the cost : Build a utility app that helps their customers figure out the cost of items in the countries they visit on a trip. Bill thinks the app should run on any mobile phone, laptop, or desktop computer, since his customers come from all over the world.
Engineering connects to the material in our class : write a 2-page report, single spaced, font 12 pts. Times New Roman, and 1 inch margins. Your report should contain a discussion of how any aspect of what you learned in your visit(s) connects to any class material (Ch. 1 thru 14) covered. Tell m..
Explain workforce planning as to its purpose : In a 2 page paper, discuss the following: Explain workforce planning as to its purpose. Describe methods for conducting workforce planning and detail desired outcomes
Object moving in a circle at constant speed : The radius of the path of an object moving in a circle at constant speed is halved. If the speed remains the same, the centripetal force needed is
Find information about judaism, christianity and islam : find information about Judaism, Christianity and Islam. I cannot seem to find things that I can compare between the three regarding their history, specifically in Palestine. Are there any similarities between them?

Reviews

Write a Review

 

Python Programming Questions & Answers

  Implement your algorithm in python

Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified and reinforce topic material related to the programming work cycle, and the input, processing, output program structure.

  Recursion to write a python function

Use recursion to write a Python function depth(LL), where LL is a nested list of lists of lists etc. of numbers (i.e., oat and int) and strings. We want to return the depth of nesting, i.e., how often, maximally, there is a list in a list etc

  Python journeyman

What are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status?

  The dictionary order based on the ascii order

Needless to say, the dictionary order based on the ASCII order is not what a real-world indexing software wants. So, we want to implement the dictionary order of strings in the standard wa

  Data file is a comma separated

The data file is a comma separated text values stored in a file with '.CSV' extension. The file has five columns corresponding to employee data fields listed above.

  Create an inheritance relationship between two classes

For this assignment you will create a simple class hierarchy. You will create an inheritance relationship between two classes -- a Friend class and a Person class - Friend will inherit Person

  The program should allow the student

The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

  Improve the code for the haunted house game

Improve the readability of the code by improving the function names, variables, and loops, as well as whitespace. Document these changes in your journal and define a win condition for the game, for example, collecting all items and returning to the..

  Define three types of programming errors

Define three types of programming errors and explain with examples

  Python program that reads in a series of positive integers

Write a Python program that reads in a series of positive integers and writes out theproduct of all the integers less than 25 and the sum of all the integers greater than or equal to 25. Use 0 as a sentinel value

  Design a function that accepts an integer

Design a function that accepts an integer argument and returns the sum of all the integers from 1 up to the number passed as an argument. For example, if 50 is passed as an argument, the function will return the sum of 1, 2, 3, 4, . . . 50. Use recur..

  The interest rate per period

The interest rate per period. For example, if your loan's interest is 6.5% per year, and you are paying monthly, this would be 6.5%/12. If you are paying every two weeks, r would be 6.5%/26, because there are 26 two-week periods in a year.

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