Build a utility app that helps their customers figure out


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 = 85.9474 JPY\n\n

\n\n\n\n
\n\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 = 0.9969 AUD\n

value="Convert">\n

\n

value=ei=82b_VfClA8aP0gS38LKoAQ>\n\n\n

\n\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

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Build a utility app that helps their customers figure out
Reference No:- TGS01254411

Expected delivery within 24 Hours

1958049

Questions
Asked

3,689

Active Tutors

1440369

Questions
Answered

Start Excelling in your courses, Ask a tutor for help and get answers for your problems !!

ask Question