Programming assignment due this sunday
Assignment2a-StayAtHomeShopping IFB104 Building IT Systems Semester 1, 2020 Assignment 2, Part A: Stay-at-Home Shopping (21%, due 11:59pm Sunday, May 24th, 2020) Overview This is the first part of a two-part assignment. This part is worth 21% of your final grade for IFB104. Part B will be worth a further 4%. Part B is intended as a last-minute extension to the assignment, thereby testing the maintainability of your solution to Part A and your ability to work under time pressure. The instructions for completing Part B will not be released until Week 11. Whether or not you complete Part B you will submit only one solution, and receive only one mark, for the whole 25% assignment. Motivation We now live in a world where everyone must stay at home as much as possible and the basic necessities of life are hard to obtain due to supply chains being overloaded. As a result, online shopping is more important than ever before. However, we may have little choice about the products available to us and the number of items we can buy may be restricted. Here you will develop a Python program that provides such a contemporary, online shopping experience. Your program will have a Graphical User Interface that allows its user to view and order prod- ucts available online, but it will offer a limited ability to choose what the user wants. Users will not be able to select individual items but must take whatever items are currently available in certain categories as a job lot. Also, users can only buy one of each product. The products and their prices can be seen in the GUI, but if the user wants more detail they can export an HTML document containing images of the products. This “capstone” assignment is designed to incorporate all of the concepts taught in IFB104. To complete it you will need to: (a) use Tkinter to create an interactive Graphical User Inter- face; (b) download web documents using a Python script and use pattern matching to extract specific elements from them; and (c) generate an HTML document containing online images. Goal In this assignment you will develop an online shopping program which lets its users select from several categories of products and view their prices (in the GUI) and images (in a web browser). The shopper can choose to buy all the items on offer in a certain category, but has no choice over individual product selections, i.e., purchases are “all or nothing”. Also, the shopper can add products from each category to their shopping cart only once, due to temporary shortages. There must be at least four distinct categories of products for sale. Products on offer are ex- tracted from lists offered by “real” online shops. Two categories are derived from previously- downloaded web documents and never change, but the other two categories must be derived from “live” web documents currently online which may be different each time they are down- loaded. The live web documents must come from sources that are updated frequently. You have a free choice of what categories of products your online shopping program will offer. Categories could be: • clothing, • electrical goods, IFB104 Building IT Systems Semester 1, 2020 • books and magazines, • motor vehicles, • furniture, • toys and games • jewellery and cosmetics, • food and drink, • medical supplies, • et cetera Whatever categories you choose, you must be able to find online web documents that contain regularly-updated lists of such products. For resilience the two “live” categories must come from different online retailers, as insurance against problems accessing one of the web sites. For each product category the corresponding online web document must include at least five products for sale at all times. For each product the document must include its name, an image of the product, and a price. Appendix A below lists many sites which may be suitable for this assignment, but you are encouraged to find your own of personal interest. For the “live” prod- uct categories the chosen web documents must be updated regularly, preferably hourly but at least daily. Using such web sites as your data source, you are required to build an IT system with the following general architecture. Your solution will be a Python program with a Graphical User Interface. Under the user’s control, it extracts lists of products from four distinct web documents. Two of the web docu- ments are stored locally in the same folder as the Python script and never change. We will IFB104 Building IT Systems Semester 1, 2020 assume these products are “old stock” and you can use them to help perfect your data extraction code. The other source of web documents is the “live” Internet. In this case the web documents are downloaded when your program runs and will likely be different each time you run your code. This is more realistic but obviously more challenging. Having extracted the product lists from one of these sources, your program must display the product names and prices in the GUI. The user can also elect to see images of the products in an exported HTML document which can be viewed in their preferred web browser. (This is necessary because Tkinter cannot display all the image formats used on the web.) Finally, the user can elect to add all the items in the currently-selected category to their shopping cart. However, they have no choice of individual products and must take a job lot of all products currently available, and can only do so once per category, due to supply chain shortages. Illustrative example To demonstrate the idea, below is our own stay-at-home shopping program, which uses data extracted from four different web sites. The screenshot below shows our example solution’s GUI when it first starts. We’ve called our online shop Pandemic Products and have included a relevant image to serve as the shop’s logo. The GUI offers the user four distinct categories of products. Two categories, “Face Masks” and “Survival Gear” are static and are never updated. We assume these are old stock which IFB104 Building IT Systems Semester 1, 2020 the retailer is waiting to be delivered from the warehouse and have thus labelled them “Old stock on order”. The other two categories, “Toilet Paper” and “Medical Supplies”, are “live” and represent products for sale online right now. These two categories will likely contain dif- ferent products each time we check because both web sites we use for them (Etsy and Amazon) are updated frequently. The user can select a category of items by clicking on the corresponding radio button. For instance, the user may choose to look at survival gear first: The first five products available in this category are listed in a text widget, along with their prices. This information was sourced from a web document previously downloaded from Crime Zappers via the URL shown at the bottom of the list above and stored in the same folder as our Python program. Our program uses pattern matching to extract the necessary elements from the web document; if a different document from the same web site was inserted in its place our program would still work correctly. In this case the user decides not to buy these products and instead selects the other “old stock” category, face masks, which causes the GUI to be updated as shown below. IFB104 Building IT Systems Semester 1, 2020 Intrigued by these products, the user decides to find out more about them by pressing the “Show images” button. This causes our GUI to export an HTML document called product_im- ages.html. When opened in a web browser, this document shows images of the five prod- ucts available in this category, as follows. (We’ve split the long document in half below.) IFB104 Building IT Systems Semester 1, 2020 The exported document contains titles identifying the shopping program and the product cate- gory, a hyperlink to the original source of the product data, and the names and photos of the five products. Satisfied with these products, the shopper then presses the “Add products to cart” button to add all five products to their shopping cart. Importantly, the user has no ability to select particular products; they must accept the entire job lot. At this point our shopper becomes greedy and decides to get more of these products. However, when the “add to cart” button is pressed again the shopper is informed of current purchase restrictions caused by panic buying. Suitably chastened, our shopper next decides to check the “live” categories and first selects medical supplies: IFB104 Building IT Systems Semester 1, 2020 This time the data is downloaded directly from a web site, Amazon’s Best Sellers. (The long- winded product names are exactly as they appear on the source web site.) The user again presses the button to show images and the product_images.html file is updated accord- ingly: IFB104 Building IT Systems Semester 1, 2020 However, our shopper is disappointed to find that most of the medical supplies currently avail- able in this category are face masks. Having already chosen face masks from another category, the user decides not to select these products too. Our user’s attention then turns to the “live” toilet paper category. The source web site for this category, Etsy, is updated frequently, and produced the following result at the time of writing. Again our shopper is sufficiently intrigued by these products to view their images: IFB104 Building IT Systems Semester 1, 2020 Our shopper is disappointed, but not surprised, to find that only novelty items mentioning toilet paper are currently available, rather than any actual paper! (And, again, the very long product names are exactly how they appear on the original web site. Similarly, the prices are formatted as per the source web document.) Nonetheless, our shopper likes the “Hello Sweet Cheeks” toilet paper holder and decides to buy it. However,