Programming Assignment #1
Programming Assignment #1
CSE 452: Fall 2004
Due Date: 10/13/05
Instructions: This programming assignment is designed to develop your Python programming skills and to illustrate how object oriented programming can be used for web applications. This assignment is the first step towards our final system—an online shopping system. In particular, the assignment will familiarize you with generating web pages dynamically using Python. All files are to be handed-in by midnight on the due date shown above.
Programming Exercises:
Explanation:
In this assignment, you should implement the GUI (Graphical User Interface) part of the online—shopping system, E-SPARTY. You will be developing a Python program that will generate the appropriate web page(s) for E-SPARTY.
1. The resulting web interface should:
• Display at least 3 categories of goods for purchase (the number should be flexible and easily modifiable for future assignments).
• Display a table of goods available for purchase for each category. Each table should have the same basic appearance. The table should minimally list: name and description of item, unit price, and quantity.
• There should be some representation of the current status of their purchases (e.g., the contents of their shopping cart). For now, you should have the interface that would allow users to change the contents of their shopping cart (e.g., remove items, change quantity.). Those operations need not be functional for the current assignment, but will be needed in an upcoming assignment.
2. Create a UML class diagram depicting the design of your Python system. Be sure to include inheritance and polymorphism in your design. Describe your design, including a data dictionary explaining all the elements of your class diagram (e.g., classes, attributes, and operations).
3. Be sure to document your code carefully and thoroughly.
4. Create a README file explaining how to run your Python program, how to use the resulting web application, and any other special instructions needed to understand your solution.
Below are some sample code snippets that illustrate some key features in Python that might be useful in designing your solution.
(Hyperlink object): (HTMLObject is some generic HTML object, you can define it to have minimal functionality.)
---------------------------------------------------
class HTMLHyperlink(HTMLObject):
#The object's constructor
def __init__(self,theURL,theText):
self.LinkURL=theURL
self.LinkText=theText
def writeHTML(self):
print("" + self.LinkText + "\n")
This simple class is created for the sole purpose of creating a hyperlink. You can extend it through inheritance. All the object does, when initialized, is store its link values locally. Then when the parent object (say an HTML form or a table) calls its writeself function, it returns the fully formed HTML code.
For example suppose we initialize an instance of HTMLHyperlink:
MyLink=HTMLHyperlink (, "Michigan
State University Department of Computer Science");
Calling Mylink.writeHTML() returns:
"Michigan State's department of Computer Science\n"
You can extend its functionality through inheritance to create an object that makes a picture hyperlink. For example:
class HTMLPictureHyperlink(HTMLHyperlink):
#The object's constructor
def __init__(self,theURL,theImageURL):
HTMLHyperlink.init(self,theURL,"")
As you can see, all this does is create a special HTMLHyperlink with an image tag in place of the usual link text. When HTMLPictureHyperlink's writeHTML() function is called, it will return a fully formed hyperlink with a picture displayed as a link instead of text!
Suppose you have a class HTMLMenu that also inherits HTMLObject's properties, but it also has children of type HTMLHyperlink. These would be the different menu items (perhaps arranged in a table, or listed individually on each line).
When you call the HTMLMenu's writeHTML() function, it might look something like:
def writeHTML(menuTitle,menuEntries) :
ReturnValue= " "
returnValue = menuTitle + "";
for i in range(len(menuEntries) :
returnValue += menuEntries[i].writeHTML() + "";
returnValue += "\n”
where menuTitle, and menuEntries are variables owned by HTMLMenu and they contain the menu's title and their hyperlinks, respectively. menuEntries is a list of HTMLPictureHyperlink objects or HTMLHyperlink objects.
Therefore, calling HTMLMenu's writeHTML() could produce code like this:
A Sample Menu
Michigan State's department of Computer Science
Michigan State's department of Engineering
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- writing assignment for 2nd grade
- aesop substitute assignment aesop online
- 6th grade writing assignment ideas
- 6th grade writing assignment pdf
- 9th grade writing assignment worksheet
- 9th grade writing assignment classroom
- 10th grade writing assignment idea
- biol 101 individual assignment 1
- unit 1 assignment sequences and series
- assignment 1 1 introductory speech outline
- mathematical literacy grade 10 assignment 1 2021 finance
- major assignment 1 mat 144