{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "nQu8_e9DzHBf" }, "source": [ "# CSCI 127 Program 5: Wacky Packages" ] }, { "cell_type": "markdown", "metadata": { "id": "YHpATE1wzHBh" }, "source": [ "### **Student Name(s):**\n", "### **Today's Date:** " ] }, { "cell_type": "markdown", "metadata": { "id": "Gd8YViX1yei1" }, "source": [ "---\n", "# ASSIGNMENT INFORMATION\n", "___\n", "## Logistics\n", "* Due Date: Friday, November 17th no later than 11:58 p.m.\n", "* Partner Information: You may complete this assignment individually or with exactly one partner. If you work with a partner, you must both be enrolled in the same lab section. (Otherwise, you and your partner will receive no credit.)\n", "* Submission Instructions (working alone): Upload your solution, entitled YourFirstName-YourLastName-Program5.ipynb to the BrightSpace Program 5 Dropbox.\n", "* Submission Instructions (working with one lab mate): Upload your solution, renamed to YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Program5.ipynb to the BrightSpace Program 5 Dropbox. Note: If you work with a partner, only one person needs to submit a solution. If you both submit a solution, the submission that will be graded is the one from the partner whose last name comes alphabetically first.\n", "* Deadline Reminder: Once the submission deadline passes, BrightSpace will no longer accept your Python submission and you will no longer be able to earn credit. Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned.\n", "\n", "## Learning outcomes\n", "* Utilize NumPy arrays to solve a problem.\n", "* Utilize object-oriented programming to solve a problem.\n", "\n", "## Wacky Packages Background\n", "* Wacky Packages were issued by the Topps Chewing Gum Company to spoof well-known brands.\n", "* [This page](https://wackypacks.com/stickers/1st_series/whitebacks/album_smaller_images.html) shows the the fronts of 30 cards that were issued in 1973.\n", "* For this assignment, you are going to write a program that keeps track of a Wacky Packages collection.\n", "* The values of the cards are taken from the NM-MT 8 (near mint 8) condition category on [this page](https://www.psacard.com/priceguide/non-sports-tcg-card-values/1973-wacky-packages-series-1/1003).\n", "\n", "## Assignment\n", "* Supply the missing WackyPackageSeries methods such that the following output is produced when ```main()``` is run using input files [series1.csv](https://drive.google.com/file/d/1S1mvzUwrgUIIlq-oxcDh3gnJhiGllzur/view?usp=sharing) and [mycards.csv](https://drive.google.com/file/d/1gs5dkM3CQUPv76iSby8pk_7otU3lNaH9/view?usp=drive_link). You will need to download these two csv files to complete the assignment.\n", "\n", "```\n", "My 1973 collection of Topps Wacky Packages\n", "\n", "Number Description Value Owned\n", "------ ----------- ----- -----\n", "6 6-Up Beverage 50.00 0\n", "30 Band-Ache Strips 600.00 0\n", "3 Breadcrust Hash 50.00 0\n", "24 Camals 85.00 0\n", "17 Canada Wet Fink 50.00 0\n", "2 Chock Full O'Bolts 50.00 0\n", "20 Cover Ghoul 75.00 0\n", "10 Crust Toothpaste 50.00 0\n", "18 Dopey Cream 110.00 0\n", "1 Duzn't Detergent 50.00 0\n", "5 Gadzooka Gum 100.00 0\n", "11 Grave Train 300.00 0\n", "15 Horrid Deoderant 50.00 0\n", "22 Hostage Cupcakes 65.00 0\n", "4 Jail-O Dessert 100.00 0\n", "23 Kook-Aid 275.00 0\n", "27 Lavirus Mouthwash 150.00 0\n", "16 Liptorn Soup 50.00 0\n", "7 Maddie Boy 50.00 0\n", "13 Minute Lice 110.00 0\n", "12 Mrs. Klean 50.00 0\n", "29 Mutt's Juice 150.00 0\n", "28 Paul Maul Cigarettes 200.00 0\n", "26 Pure Hex 50.00 0\n", "8 Quacker Oats 50.00 0\n", "14 Skimpy 50.00 0\n", "19 Spray Nit 50.00 0\n", "25 Tied Detergent 50.00 0\n", "21 Vicejoy Cigarettes 75.00 0\n", "9 Weakies Breakfast Cereal 50.00 0\n", "\n", "My 1973 collection of Topps Wacky Packages\n", "\n", "Number Description Value Owned\n", "------ ----------- ----- -----\n", "6 6-Up Beverage 50.00 1\n", "30 Band-Ache Strips 600.00 0\n", "3 Breadcrust Hash 50.00 1\n", "24 Camals 85.00 0\n", "17 Canada Wet Fink 50.00 1\n", "2 Chock Full O'Bolts 50.00 1\n", "20 Cover Ghoul 75.00 1\n", "10 Crust Toothpaste 50.00 0\n", "18 Dopey Cream 110.00 2\n", "1 Duzn't Detergent 50.00 0\n", "5 Gadzooka Gum 100.00 1\n", "11 Grave Train 300.00 1\n", "15 Horrid Deoderant 50.00 1\n", "22 Hostage Cupcakes 65.00 0\n", "4 Jail-O Dessert 100.00 2\n", "23 Kook-Aid 275.00 0\n", "27 Lavirus Mouthwash 150.00 3\n", "16 Liptorn Soup 50.00 1\n", "7 Maddie Boy 50.00 1\n", "13 Minute Lice 110.00 0\n", "12 Mrs. Klean 50.00 2\n", "29 Mutt's Juice 150.00 0\n", "28 Paul Maul Cigarettes 200.00 1\n", "26 Pure Hex 50.00 1\n", "8 Quacker Oats 50.00 1\n", "14 Skimpy 50.00 0\n", "19 Spray Nit 50.00 2\n", "25 Tied Detergent 50.00 0\n", "21 Vicejoy Cigarettes 75.00 1\n", "9 Weakies Breakfast Cereal 50.00 1\n", "\n", "Value of collection = $2320.00\n", "Number of missing cards = 10\n", "Cost of purchasing missing cards = $1485.00\n", "\n", "```\n", "## Grading\n", "* 20 points. The ```WackyPackageSeries``` methods use object-oriented programming properly. In particular, these methods should not access individual fields of ```WackyPackageCard``` instances directly; instead, they should access these fields through the methods that are provided by the ```WackyPackageCard``` class. (5 points for each improper access up to 20 points.)\n", "* 20 points. The ```process_series_information``` method results in the correct output being produced. (10 points for each type of error up to 20 points.)\n", "* 20 points. The ```process_collection_information``` method results in the correct output being produced. (10 points for each type of error up to 20 points.)\n", "* 10 points. The ```__str__``` method is correct. (5 points for each type of formatting difference up to 10 points.)\n", "* 10 points. The ```collection_value``` method is correct. (All or nothing.)\n", "* 10 points. The ```determine_missing_information``` method is correct. (All or nothing.)\n", "* 10 points. The methods you write are properly commented, easy to understand and do not contain unnecessary code. (3 points for each type of improvement up to 10 points.)\n" ] }, { "cell_type": "markdown", "metadata": { "id": "M8HveN9GzHBi" }, "source": [ "___\n", "# PROGRAM BEGINS HERE\n", "___" ] }, { "cell_type": "markdown", "source": [ "Import ```numpy```. Import the ```files``` submodule from ```google.colab``` library." ], "metadata": { "id": "d47fGf9_4CdV" } }, { "cell_type": "code", "source": [ "import numpy as np\n", "from google.colab import files" ], "metadata": { "id": "zsxe0smT4GCJ" }, "execution_count": 1, "outputs": [] }, { "cell_type": "markdown", "source": [ "For the following step to work, you need to have downloaded the input files [series1.csv](https://drive.google.com/file/d/1S1mvzUwrgUIIlq-oxcDh3gnJhiGllzur/view?usp=sharing) and [mycards.csv](https://drive.google.com/file/d/1gs5dkM3CQUPv76iSby8pk_7otU3lNaH9/view?usp=drive_link) to your local hard disk. Execute the next line of code and then select the two files from the appropriate directory." ], "metadata": { "id": "d-2vHqzIqjHp" } }, { "cell_type": "code", "source": [ "the_files = files.upload()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 114 }, "id": "68ua4ocHqfiu", "outputId": "f7e7331e-1e66-414b-b992-a15aa359e6de" }, "execution_count": 2, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "" ], "text/html": [ "\n", " \n", " \n", " Upload widget is only available when the cell has been executed in the\n", " current browser session. Please rerun this cell to enable.\n", " \n", " " ] }, "metadata": {} }, { "output_type": "stream", "name": "stdout", "text": [ "Saving mycards.csv to mycards.csv\n", "Saving series1.csv to series1.csv\n" ] } ] }, { "cell_type": "markdown", "source": [ "Open the files and check to see that they imported correctly. ***(Note: You may edit the code to open the csv files, but it is not neccessary to complete the assignment.)***" ], "metadata": { "id": "WVN5tky_rlTP" } }, { "cell_type": "code", "source": [ "my_cards = open(\"/content/mycards.csv\", \"r\").readlines()\n", "print(my_cards, \"\\n\", type(my_cards))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "1E1nxJHwisnq", "outputId": "2cffa245-820c-4e50-eb28-b355ab7139f2" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "['6-up beverage\\n', 'breadcrust hash\\n', 'canada wet fink\\n', 'cover ghoul\\n', 'dopey cream\\n', 'gadzooka gum\\n', 'horrid deoderant\\n', 'jail-o dessert\\n', 'lavirus mouthwash\\n', 'maddie boy\\n', 'mrs. klean\\n', 'paul maul cigarettes\\n', 'quacker oats\\n', 'spray nit\\n', 'vicejoy cigarettes\\n', 'weakies breakfast cereal\\n', 'spray nit\\n', 'pure hex\\n', 'mrs. klean\\n', 'liptorn soup\\n', 'jail-o dessert\\n', 'grave train\\n', 'dopey cream\\n', \"chock full o'bolts\\n\", 'breakcrust hash\\n', 'LaViRUS MOUTHwash\\n', ' lavirus mouthWASH \\n', 'nonexistent card\\n', 'another nonexistent card'] \n", " \n" ] } ] }, { "cell_type": "code", "source": [ "series_1 = open(\"/content/series1.csv\", \"r\").readlines()\n", "print(series_1, \"\\n\", type(series_1))" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "v2T9rYVbsCuG", "outputId": "ee2a345f-3728-4a6c-b968-ec63bf2407c3" }, "execution_count": 4, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "['6,6-Up Beverage,50\\n', '30,Band-Ache Strips,600\\n', '3,Breadcrust Hash,50\\n', '24,Camals,85\\n', '17,Canada Wet Fink,50\\n', \"2,Chock Full O'Bolts,50\\n\", '20,Cover Ghoul,75\\n', '10,Crust Toothpaste,50\\n', '18,Dopey Cream,110\\n', \"1,Duzn't Detergent,50\\n\", '5,Gadzooka Gum,100\\n', '11,Grave Train,300\\n', '15,Horrid Deoderant,50\\n', '22,Hostage Cupcakes,65\\n', '4,Jail-O Dessert,100\\n', '23,Kook-Aid,275\\n', '27,Lavirus Mouthwash,150\\n', '16,Liptorn Soup,50\\n', '7,Maddie Boy,50\\n', '13,Minute Lice,110\\n', '12,Mrs. Klean,50\\n', \"29,Mutt's Juice,150\\n\", '28,Paul Maul Cigarettes,200\\n', '26,Pure Hex,50\\n', '8,Quacker Oats,50\\n', '14,Skimpy,50\\n', '19,Spray Nit,50\\n', '25,Tied Detergent,50\\n', '21,Vicejoy Cigarettes,75\\n', '9,Weakies Breakfast Cereal,50\\n'] \n", " \n" ] } ] }, { "cell_type": "markdown", "source": [ "Create a class called ```WackyPackageCard```. Instances of this class represent one card type. ***(Note: Do not edit the code for the*** ```WackyPackageCard``` ***class.)***" ], "metadata": { "id": "kUyIycDw4a6h" } }, { "cell_type": "code", "source": [ "class WackyPackageCard:\n", " def __init__(self, number, description, value):\n", " self.number = number\n", " self.description = description\n", " self.value = value\n", " self.cards_owned = 0\n", "\n", " def __str__(self):\n", " return \"{:<10d}{:25}{:10.2f}{:10d}\".format(self.number, self.description, self.value, self.cards_owned)\n", "\n", " def get_number(self):\n", " return self.number\n", "\n", " def get_description(self):\n", " return self.description\n", "\n", " def get_value(self):\n", " return self.value\n", "\n", " def get_cards_owned(self):\n", " return self.cards_owned\n", "\n", " def set_cards_owned(self, number):\n", " self.cards_owned = number" ], "metadata": { "id": "1puvnk_v33JB" }, "execution_count": 5, "outputs": [] }, { "cell_type": "markdown", "source": [ "Create a class called ```WackyPackageSeries```. ***(Note: Add code to create the missing methods for the*** ```WackyPackageSeries``` ***class. This is the only block of code that you need to edit to complete this assignment.)***" ], "metadata": { "id": "aFsyLCZe4H1c" } }, { "cell_type": "code", "source": [ "class WackyPackageSeries:\n", " def __init__(self, manufacturer, year, how_many):\n", " self.manufacturer = manufacturer\n", " self.year = year\n", " self.how_many = how_many\n", " self.cards = np.ndarray(how_many, dtype=WackyPackageCard)\n", "\n", " # Provide code for the methods here. Do not modify the constructor.\n", " def __str__(self):\n", " pass\n", "\n", " def process_series_information(self, series_info):\n", " pass\n", "\n", " def process_collection_information(self, collection_info):\n", " pass\n", "\n", " def collection_value(self):\n", " pass\n", "\n", " def determine_missing_information(self):\n", " pass\n", "\n" ], "metadata": { "id": "OIzr0owM4WYF" }, "execution_count": 8, "outputs": [] }, { "cell_type": "markdown", "source": [ "Define the ```main``` function and run it. ***(Note: Do not edit any of the following code. If you have created all of the necessary methods in the*** ```WackyPackageSeries``` ***class, then the following code will create the correct output. Be sure to check your output against the sample output provided above.)***" ], "metadata": { "id": "8917F1VCOI5S" } }, { "cell_type": "code", "source": [ "def main():\n", " my_collection = WackyPackageSeries(\"Topps\", 1973, 30)\n", " my_collection.process_series_information(series_1)\n", " print(my_collection)\n", " my_collection.process_collection_information(my_cards)\n", " print(my_collection)\n", " print(\"Value of collection = ${:.2f}\".format(my_collection.collection_value()))\n", " number_of_missing_cards, cost_of_missing_cards = my_collection.determine_missing_information()\n", " print(\"Number of missing cards =\", number_of_missing_cards)\n", " print(\"Cost of purchasing missing cards = ${:.2f}\".format(cost_of_missing_cards))\n", "\n", "main()" ], "metadata": { "id": "8QbNqmtx-mI1", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "c3ae7924-facc-4fac-ec89-b2faeded11d1" }, "execution_count": 9, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "My 1973 collection of Topps Wacky Packages\n", "\n", "Number Description Value Owned\n", "------ ----------- ----- -----\n", "6 6-Up Beverage 50.00 0\n", "30 Band-Ache Strips 600.00 0\n", "3 Breadcrust Hash 50.00 0\n", "24 Camals 85.00 0\n", "17 Canada Wet Fink 50.00 0\n", "2 Chock Full O'Bolts 50.00 0\n", "20 Cover Ghoul 75.00 0\n", "10 Crust Toothpaste 50.00 0\n", "18 Dopey Cream 110.00 0\n", "1 Duzn't Detergent 50.00 0\n", "5 Gadzooka Gum 100.00 0\n", "11 Grave Train 300.00 0\n", "15 Horrid Deoderant 50.00 0\n", "22 Hostage Cupcakes 65.00 0\n", "4 Jail-O Dessert 100.00 0\n", "23 Kook-Aid 275.00 0\n", "27 Lavirus Mouthwash 150.00 0\n", "16 Liptorn Soup 50.00 0\n", "7 Maddie Boy 50.00 0\n", "13 Minute Lice 110.00 0\n", "12 Mrs. Klean 50.00 0\n", "29 Mutt's Juice 150.00 0\n", "28 Paul Maul Cigarettes 200.00 0\n", "26 Pure Hex 50.00 0\n", "8 Quacker Oats 50.00 0\n", "14 Skimpy 50.00 0\n", "19 Spray Nit 50.00 0\n", "25 Tied Detergent 50.00 0\n", "21 Vicejoy Cigarettes 75.00 0\n", "9 Weakies Breakfast Cereal 50.00 0\n", "\n", "My 1973 collection of Topps Wacky Packages\n", "\n", "Number Description Value Owned\n", "------ ----------- ----- -----\n", "6 6-Up Beverage 50.00 1\n", "30 Band-Ache Strips 600.00 0\n", "3 Breadcrust Hash 50.00 1\n", "24 Camals 85.00 0\n", "17 Canada Wet Fink 50.00 1\n", "2 Chock Full O'Bolts 50.00 1\n", "20 Cover Ghoul 75.00 1\n", "10 Crust Toothpaste 50.00 0\n", "18 Dopey Cream 110.00 2\n", "1 Duzn't Detergent 50.00 0\n", "5 Gadzooka Gum 100.00 1\n", "11 Grave Train 300.00 1\n", "15 Horrid Deoderant 50.00 1\n", "22 Hostage Cupcakes 65.00 0\n", "4 Jail-O Dessert 100.00 2\n", "23 Kook-Aid 275.00 0\n", "27 Lavirus Mouthwash 150.00 3\n", "16 Liptorn Soup 50.00 1\n", "7 Maddie Boy 50.00 1\n", "13 Minute Lice 110.00 0\n", "12 Mrs. Klean 50.00 2\n", "29 Mutt's Juice 150.00 0\n", "28 Paul Maul Cigarettes 200.00 1\n", "26 Pure Hex 50.00 1\n", "8 Quacker Oats 50.00 1\n", "14 Skimpy 50.00 0\n", "19 Spray Nit 50.00 2\n", "25 Tied Detergent 50.00 0\n", "21 Vicejoy Cigarettes 75.00 1\n", "9 Weakies Breakfast Cereal 50.00 1\n", "\n", "Value of collection = $2320.00\n", "Number of missing cards = 10\n", "Cost of purchasing missing cards = $1485.00\n" ] } ] } ], "metadata": { "colab": { "provenance": [] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 0 }