Beruflich Dokumente
Kultur Dokumente
Table of Contents
Executive Summary..2
Source Code..2
UML63
Design Patterns...64
Sequence Diagrams...67
Use Cases.82
White Box Testing..87
Black Box Testing..97
Presentation...103
Executive Summary
This team developed an application that is a mock version of an online shopping site.
The application is referred to as Shopazon. The application will allow users to browse a
variety of objects and purchase the objects of their choice. The application allows the
user to purchase items in multiple ways. These ways including credit cards and PayPal.
The user will also be able to purchase items individually or in bulk using a shopping
cart.
Source Code
Adapter
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
class adapter : allInterface
{
//Creates object for non-word format.
otherInterface oi;
Kitchen k;
public adapter(Kitchen k)
{
this.k = k;
//Simpily matching the filetype to correct class.
//oi = new Kitchen("Knife", 45,
"pack://application:,,,/WpfApplication3;component/Resources/4star.PNG"
, counter2,"WOW WHAT A MOP!",2);
oi = k;
}
public void printStuff()
{
//
Debug.WriteLine(price+" "+name);
}
public int getPrice()
{
return k.getPrice();
}
public String getName()
{
return k.getName();
}
public String getImage()
3
{
return k.getImage();
}
public String getDesc()
{
return k.getDesc();
}
public int getRating()
{
return k.getRating();
}
public Iterator getIterator()
{
return null;
}
}
}
allCategory
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public class allCategory : allInterface
{
Kitchen k;
allInterface oi;
List<allInterface> abc = new List<allInterface>();
4
{
List<allInterface> abc;
int index;
public NameIterator(List<allInterface> abc)
{
this.abc = abc;
}
public Boolean hasNext()
{
if (index < abc.Count())
{
return true;
}
return false;
}
public Object next()
{
if (this.hasNext())
{
return abc[index++].getName();
}
return null;
}
}
public allCategory(Kitchen k)
{
this.k = k;
oi = new adapter(k);
}
public allCategory()
{
}
//You know
int price;
String name;
String image;
String desc;
//This is to see how many products we have in an arraylist.
int itemCount;
int rating;
//Adding products to categories via arraylist
public void addObject(allInterface a)
{
abc.Add(a);
}
public List<allInterface> getObjectArray()
{
return abc;
}
public allInterface getObjectKitchen()
{
return oi;
}
//DEBUG
public void printout()
{
foreach (var compositeInterface in abc)
{
// getArrayListItem(0);
//
Debug.WriteLine("HELLO");
// Debug.WriteLine(compositeInterface.getDesc());
//Debug.WriteLine(name);
//counter=0;
}
}
//DEBUG
6
public void printStuff()
{
//
Debug.WriteLine(name,price);
}
//getters and setters.
public int getPrice()
{
return price;
}
public allInterface getObject()
{
return object1;
}
public String getImage()
{
return image;
}
public String getName()
{
return name;
}
public int getListSize()
{
return itemCount = abc.Count();
}
public int getRating()
{
return rating;
}
//This does a bulk of our work.
public void getArrayListItem(int index)
{
//Stores the product of index as our object
object1 = abc[index];
//Stores the price, name, and image location.
price = object1.getPrice();
name = object1.getName();
image = object1.getImage();
//DEBUG
7
object1.printStuff();
//object1.printStuff();
// Debug.WriteLine(price);
}
public String getDesc()
{
return desc;
}
}
}
allInterface
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public interface allInterface
{
void printStuff();
String getName();
int getPrice();
String getImage();
String getDesc();
int getRating();
Iterator getIterator();
}
}
Books
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public class Books : allInterface
{
String name;
int price;
String image;
String desc;
int rating;
public Books(String name, int price, String image, String
desc, int rating)
{
this.name = name;
this.price = price;
this.image = image;
this.desc = desc;
this.rating = rating;
}
public void printStuff()
{
//
Debug.WriteLine(price+" "+name);
}
public int getPrice()
{
return price;
}
public String getName()
{
return name;
}
public String getImage()
{
return image;
}
public String getDesc()
{
return desc;
}
public int getRating()
{
return rating;
}
9
public Iterator getIterator()
{
return null;
}
}
}
Cleaning
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public class Cleaning : allInterface
{
String name;
int price;
String image;
String desc;
int rating;
public Cleaning(String name, int price, String image, String
desc, int rating)
{
this.name = name;
this.price = price;
this.image = image;
this.desc = desc;
this.rating = rating;
}
public void printStuff()
{
//
Debug.WriteLine(price+" "+name);
}
public int getPrice()
{
return price;
}
public String getName()
{
return name;
10
}
public String getImage()
{
return image;
}
public String getDesc()
{
return desc;
}
public int getRating()
{
return rating;
}
public String TEST()
{
return "TEST";
}
public Iterator getIterator()
{
return null;
}
}
}
Cart
using
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
/*Command Pattern*/
namespace WpfApplication3
11
{
/// <summary>
/// Interaction logic for Cart.xaml
/// </summary>
public partial class Cart : Window
{
int counterr = 0;
orderer broker = new orderer();
int counter2 = 0;
OrderItem oi1;
OrderItem oi2;
OrderItem oi3;
OrderItem oi4;
cancelItem ci1;
cancelItem ci2;
cancelItem ci3;
cancelItem ci4;
public int countItemArray = 0;
Item i;
List<Item> itemList = new List<Item>();
List<Item> itemList2 = new List<Item>();
List<Item> itemList3 = new List<Item>();
List<Item> itemList4 = new List<Item>();
List<String> cancelItems = new List<String>();
String itemsCancelled="";
public Cart()
{
InitializeComponent();
order1.Visibility = Visibility.Hidden;
order2.Visibility = Visibility.Hidden;
order3.Visibility = Visibility.Hidden;
order4.Visibility = Visibility.Hidden;
delete1.Visibility = Visibility.Hidden;
delete2.Visibility = Visibility.Hidden;
delete3.Visibility = Visibility.Hidden;
delete4.Visibility = Visibility.Hidden;
12
13
item = itemList[3];
itemimage4.Source = new BitmapImage(new
Uri(item.getImage()));
itemimage4.Visibility = Visibility.Visible;
order4.Visibility = Visibility.Visible;
delete4.Visibility = Visibility.Visible;
}
countItemArray++;
}
//itemList = itemList2;
Debug.WriteLine("AFTER+"+intt);
// Debug.WriteLine(itemList[0].getImage());
foreach (var obj in itemList)
{
Debug.WriteLine("Getting Called");
displayitem1();
}
/*
for (int iii = 0; iii < 2; iii++)
{
if (itemList[counter] == null)
{
counter2 = counter;
for (int ii = counter2; ii < 2; ii++)
{
14
if (itemList[ii] != null)
{
itemList[counter2] = itemList[ii];
displayitem1();
}
}
//itemList[counter + 1] = itemList[counter];
}
}
counter++;
*/
}
public void printcancel()
{
for (int i=0;i<cancelItems.Count();i++){
itemsCancelled += cancelItems[i]+"\n";
}
}
15
this.w5 = w5;
this.cancelItems = cancelItems;
}
}
public class cancelItem : Order
{
private Item item;
public cancelItem(Item item)
{
this.item = item;
}
public void execute()
{
item.cancel();
}
}
public class OrderItem : Order {
private Item item;
public OrderItem(Item item){
this.item = item;
16
}
public void execute() {
item.addToOrder();
}
}
public class orderer
{
public List<Order> list = new List<Order>();
public void takeOrder(Order order)
{
list.Add(order);
}
public void placeOrders(){
foreach (var obj in list)
{
obj.execute();
}
list.Clear();
// orderList.clear();
}
}
17
i = null;
itemList[0] = i;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Item i = itemList[1];
oi2 = new OrderItem(i);
broker.takeOrder(oi2);
i = null;
itemList[1]=i;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
Item i = itemList[1];
ci2 = new cancelItem(i);
broker.takeOrder(ci2);
i = null;
itemList[1] = i;
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
Item i = itemList[0];
ci1 = new cancelItem(i);
broker.takeOrder(ci1);
i = null;
itemList[0] = i;
}
private void Button_Click_4(object sender, RoutedEventArgs e)
{
//
OrderItem oi = new OrderItem(i);
broker.placeOrders();
countItemArray = 0;
printcancel();
MessageBox.Show("Item(s) deleted: "+itemsCancelled);
18
cancelItems.Clear();
itemimage1.Visibility = Visibility.Hidden;
itemimage2.Visibility = Visibility.Hidden;
itemimage3.Visibility = Visibility.Hidden;
itemimage4.Visibility = Visibility.Hidden;
order1.Visibility = Visibility.Hidden;
order2.Visibility = Visibility.Hidden;
order3.Visibility = Visibility.Hidden;
order4.Visibility = Visibility.Hidden;
delete1.Visibility = Visibility.Hidden;
delete2.Visibility = Visibility.Hidden;
delete3.Visibility = Visibility.Hidden;
delete4.Visibility = Visibility.Hidden;
recursive();
}
private void Button_Click_5(object sender, RoutedEventArgs e)
{
Item i = itemList[2];
oi3 = new OrderItem(i);
broker.takeOrder(oi3);
i = null;
itemList[2] = i;
}
private void Button_Click_6(object sender, RoutedEventArgs e)
{
Item i = itemList[3];
oi4 = new OrderItem(i);
broker.takeOrder(oi4);
i = null;
itemList[3] = i;
}
private void delete3_Click(object sender, RoutedEventArgs e)
{
Item i = itemList[2];
ci3 = new cancelItem(i);
broker.takeOrder(ci3);
i = null;
itemList[2] = i;
}
19
}
}
Clothing
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public class clothing : allInterface
{
String name;
int price;
String image;
String desc;
int rating;
public clothing(String name, int price, String image, String
desc, int rating)
{
this.name = name;
this.price = price;
20
this.image = image;
this.desc = desc;
this.rating = rating;
}
public void printStuff()
{
//
Debug.WriteLine(price+" "+name);
}
public int getPrice()
{
return price;
}
public String getName()
{
return name;
}
public String getImage()
{
return image;
}
public String getDesc()
{
return desc;
}
public int getRating()
{
return rating;
}
public String TEST()
{
return "TEST";
}
public Iterator getIterator()
{
return null;
}
}
}
cc
using System;
using System.Collections.Generic;
using System.Linq;
21
using
using
using
using
using
using
using
using
using
using
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for cc.xaml
/// </summary>
public partial class cc : Window
{
Window5 w5;
Window2 w2;
allInterface objectItem;
public cc(Window5 w5, Window2 w2, allInterface objectItem)
{
InitializeComponent();
this.w5 = w5;
this.w2 = w2;
this.objectItem = objectItem;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
w5.addItem(objectItem.getImage(), objectItem.getName());
}
}
}
Electronics
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApplication3
22
{
public class Electronics : allInterface
{
String name;
int price;
String image;
String desc;
int rating;
public Electronics(String name, int price, String image, String desc, int rating)
{
this.name = name;
this.price = price;
this.image = image;
this.desc = desc;
this.rating = rating;
}
public void printStuff()
{
// Debug.WriteLine(price+" "+name);
}
public int getPrice()
{
return price;
}
public String getName()
{
return name;
}
public String getImage()
{
return image;
}
public String getDesc()
{
return desc;
}
public int getRating()
{
return rating;
}
public Iterator getIterator()
{
23
return null;
}
}
}
Iterator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApplication3
{
public interface Iterator
{
Boolean hasNext();
Object next();
}
}
Kitchen
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public class Kitchen : otherInterface
{
String name;
int price;
String image;
string desc;
int rating;
public Kitchen(String name, int price, String image, String
desc, int rating)
{
24
this.rating = rating;
this.name = name;
this.price = price;
this.image = image;
this.desc = desc;
}
public void printStuff()
{
// Debug.WriteLine(price + " " + name);
}
public int getPrice()
{
return price;
}
public String getName()
{
return name;
}
public String getImage()
{
return image;
}
public String abc()
{
return null;
}
public string getDesc()
{
return desc;
}
public int getRating()
{
return rating;
}
public Iterator getIterator()
{
return null;
}
}
}
25
Main Window
/*CURRENT
* */
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Navigation;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Window1 w1;
public MainWindow()
{
this.Width = 1000;
this.Height = 1000;
InitializeComponent();
Background = Brushes.White;
26
get { return this.firstName; }
set
{
//
this.RaisePropertyChanged();
this.firstName = value;}
}
void SelectAllText(object sender, RoutedEventArgs e)
{
var textBox = e.OriginalSource as TextBox;
if (textBox != null)
textBox.SelectAll();
}
String aaa;
String aac="HELLO";
aaa = TextBox1.Text;
Debug.WriteLine(TextBox1.Text);
customer.Name=aac;
27
// f2.Show();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
public
public
public
public
public
String
String
String
String
String
28
public void setState(string arg) { state = arg; }
public void setZip(string arg) { zip = arg; }
}
}
otherInterface
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
namespace WpfApplication3
{
public interface otherInterface
{
void printStuff();
String getName();
int getPrice();
String getImage();
String abc();
String getDesc();
}
}
Paypal
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
29
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for PayPal.xaml
/// </summary>
///
public partial class PayPal : Window
{
Window5 w5;
Window2 w2;
allInterface objectItem;
public PayPal(Window5 w5, Window2 w2, allInterface objectItem)
{
InitializeComponent();
paypal.Source = new BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/paypal
.png"));
this.w5 = w5;
this.w2 = w2;
this.objectItem = objectItem;
}
}
}
Window1
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Drawing;
System.Linq;
System.Text;
System.Threading;
System.Threading.Tasks;
System.Windows;
30
using
using
using
using
using
using
using
using
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Animation;
System.Windows.Media.Imaging;
System.Windows.Shapes;
31
/*********************************************************************
************************************ */
//Cleaning objects
Cleaning broom = new Cleaning("Broom", 45,
"pack://application:,,,/WpfApplication3;component/Resources/broom.jpg"
,"Standard broom for cleaning up and sweeping",0);
Cleaning vac = new Cleaning("Vac", 15,
"pack://application:,,,/WpfApplication3;component/Resources/vac.jpg",
"Standard vac to vac the vac!",1);
Cleaning mop = new Cleaning("Mop", 15,
"pack://application:,,,/WpfApplication3;component/Resources/mop.jpg",
"You can use this to mop stuff",2);
Cleaning duster = new Cleaning("Duster", 15,
"pack://application:,,,/WpfApplication3;component/Resources/duster.jpg
", "Just move your dust to a new spot",3);
Cleaning mop2 = new Cleaning("Mop2", 15,
"pack://application:,,,/WpfApplication3;component/Resources/mop.jpg",
"WOW WHAT A MOP!", 2);
Cleaning broom1 = new Cleaning("Broom1", 45,
"pack://application:,,,/WpfApplication3;component/Resources/broom.jpg"
, "WOW WHAT A BROOM!", 0);
Cleaning vac1 = new Cleaning("Vac1", 15,
"pack://application:,,,/WpfApplication3;component/Resources/vac.jpg",
"WOW WHAT A VAC!", 1);
Cleaning mop1 = new Cleaning("Mop1", 15,
"pack://application:,,,/WpfApplication3;component/Resources/mop.jpg",
"WOW WHAT A MOP!", 2);
Cleaning duster1 = new Cleaning("Duster1", 15,
"pack://application:,,,/WpfApplication3;component/Resources/duster.jpg
", "WOW WHAT A MOP!", 3);
Cleaning broom2 = new Cleaning("Broom2", 45,
"pack://application:,,,/WpfApplication3;component/Resources/broom.jpg"
, "WOW WHAT A BROOM!", 0);
Cleaning vac2 = new Cleaning("Vac2", 15,
"pack://application:,,,/WpfApplication3;component/Resources/vac.jpg",
"WOW WHAT A VAC!", 1);
/*********************************************************************
**********************************************************************
********************************/
32
/*********************************************************************
**********************************************************************
**************************/
Books b1 = new Books("Fifty Shades of Grey", 15,
"pack://application:,,,/WpfApplication3;component/Resources/50Shadesof
GreyCoverArt.jpg", "This book is awful!", 1);
Books b2 = new Books("Atlas Shrugged", 25,
"pack://application:,,,/WpfApplication3;component/Resources/AtlasShrug
ged.jpg", "boo!", 5);
Books b3 = new Books("The Old Man and the Sea", 12,
"pack://application:,,,/WpfApplication3;component/Resources/booksernest-hemingway-33898424-405-591.jpg", "It was ok", 3);
Books b4 = new Books("War and Peace", 30,
"pack://application:,,,/WpfApplication3;component/Resources/War-andPeace-w001.jpg", "Classic", 4);
/*********************************************************************
**********************************************************************
********************************/
/*********************************************************************
**********************************************************************
**************************/
Electronics e1 = new Electronics("Xbox One", 50, "
pack://application:,,,/WpfApplication3;component/Resources/xbox.jpg",
"A game system by Microsoft", 3);
Electronics e2 = new Electronics("Playstation 4", 80,
"pack://application:,,,/WpfApplication3;component/Resources/ps.png ",
"A game system by Sony", 3);
Electronics e3 = new Electronics("Wii U", 30, "
pack://application:,,,/WpfApplication3;component/Resources/wii.jpg", "
A game system by Nintendo", 4);
Electronics e4 = new Electronics("Flatscreen Television", 40,
"pack://application:,,,/WpfApplication3;component/Resources/tv.jpg ",
"A television unlike any other", 2);
33
Electronics e5 = new Electronics("Camera", 20, "
pack://application:,,,/WpfApplication3;component/Resources/camera.jpg"
, "It flashes", 3);
Electronics e6 = new Electronics("Robo Dog", 60, "
pack://application:,,,/WpfApplication3;component/Resources/dog.jpg",
"Robo Cop's companion for life", 1);
Electronics e7 = new Electronics("Ipad", 90,
"pack://application:,,,/WpfApplication3;component/Resources/ipad.jpg
", "Don't drop that apple", 3);
Electronics e8 = new Electronics("Laptop", 75,
"pack://application:,,,/WpfApplication3;component/Resources/computer.j
pg ", "It Googles things", 4);
/*********************************************************************
**********************************************************************
********************************/
/*********************************************************************
**********************************************************************
********************************/
//Kitchen Objects
Kitchen knife = new Kitchen("Knife", 100,
"pack://application:,,,/WpfApplication3;component/Resources/knife.jpg"
,"WOW WHAT A MOP!",1);
Kitchen pans = new Kitchen("Pan", 15,
"pack://application:,,,/WpfApplication3;component/Resources/pan.jpg",
"WOW WHAT A MOP!", 1);
// Kitchen fork = new Kitchen("Fork", 15,
"C:\\Users\\Stephen\\Desktop\\fork.png", counter2);
/*********************************************************************
**********************************************************************
********************************/
/*********************************************************************
**********************************************************************
**************************/
//Clothing shirt1 = new Clothing();
34
clothing c7 = new clothing("Pants", 20, "
pack://application:,,,/WpfApplication3;component/Resources/pants.jpg",
"keep those legs warm", 3);
clothing c1 = new clothing("Shoes", 30,
"pack://application:,,,/WpfApplication3;component/Resources/shoes2.jpg
", "They improve your jump", 2);
clothing c2 = new clothing("Beenie", 15,
"pack://application:,,,/WpfApplication3;component/Resources/beanie.jpg
", "Keep those ears nice and snug", 4);
clothing c3 = new clothing("Skirt", 23,
"pack://application:,,,/WpfApplication3;component/Resources/skirt.jpg
", " It is not a dress", 3);
clothing c4 = new clothing("Dress", 32,
"pack://application:,,,/WpfApplication3;component/Resources/dress.jpg
", "It is not a skirt", 3);
clothing c5 = new clothing("Shirt", 20, "
pack://application:,,,/WpfApplication3;component/Resources/shirt.jpg",
"Keep your shirt on", 3);
clothing c6 = new clothing("Tie", 5,
"pack://application:,,,/WpfApplication3;component/Resources/tie.jpg ",
"Suit up", 2);
/*********************************************************************
**********************************************************************
**************************/
public
public
public
public
allInterface
allInterface
allInterface
allInterface
object1;
object2;
object3;
object4;
35
//Dynamic Comp
public allCategory comp;
//Pass on Customer
Customer c;
//Window stuff/SINGLETON
public Window5 w5 = Window5.getWindow;
Window4 w4;
Cart kart;
public Window1(Customer c)
{
InitializeComponent();
kart = new Cart();
this.c = c;
36
booksComp.addObject(b1);
booksComp.addObject(b2);
booksComp.addObject(b3);
booksComp.addObject(b4);
clothingCategory.addObject(c1);
clothingCategory.addObject(c2);
clothingCategory.addObject(c3);
clothingCategory.addObject(c4);
clothingCategory.addObject(c5);
clothingCategory.addObject(c7);
clothingCategory.addObject(c6);
electronicComp.addObject(e1);
electronicComp.addObject(e2);
electronicComp.addObject(e3);
electronicComp.addObject(e4);
electronicComp.addObject(e5);
electronicComp.addObject(e6);
electronicComp.addObject(e7);
electronicComp.addObject(e8);
//ADAPTER STUFF
allCategory a = new allCategory(knife);
allCategory b = new allCategory(pans);
all.addObject(broom);
all.addObject(vac);
all.addObject(mop);
all.addObject(duster);
//
all.addObject(mop2);
//
all.addObject(vac1);
//
all.addObject(mop1);
//
all.addObject(duster1);
//
all.addObject(broom2);
//
all.addObject(vac2);
//
all.addObject(broom1);
all.addObject(b1);
all.addObject(b2);
all.addObject(b3);
all.addObject(b4);
all.addObject(c1);
37
all.addObject(c2);
all.addObject(c3);
all.addObject(c4);
all.addObject(c5);
all.addObject(c6);
all.addObject(c7);
all.addObject(e1);
all.addObject(e2);
all.addObject(e3);
all.addObject(e4);
all.addObject(e5);
all.addObject(e6);
all.addObject(e7);
all.addObject(e8);
all.addObject(a.getObjectKitchen());
all.addObject(b.getObjectKitchen());
KitchenCategory.addObject(a.getObjectKitchen());
KitchenCategory.addObject(b.getObjectKitchen());
//Iterator stuff for later.
displayStuff(all);
}
private void displayStuff(allCategory compValue)
{
countup = 0;
next.Visibility = Visibility.Visible;
comp = compValue;
//
button2.Visible = true;
//So countup will represent the id of an object within
that category. Its a counter, it will
//pick the first one, then increment afterwards
//Debug purposes
//
38
//When we only have 4 items... Keeps track of how many
items we have... Also
//helps us with out prev and next buttons.
count = comp.getListSize();
//Display1 is the first picture and label... This will
ALWAYS run because there
//will always be one product per category.
display1(comp);
//Finding the next product id.
countup++;
//How many products we have left.
count--;
//So once the first product is displayed we have to check
and see if there
//is even another object there to display... Well if count
is greater than zero
//then there is.
if (count > 0)
{
image02.Visibility = Visibility.Visible;
display2(comp);
countup++;
count--;
}
if (count > 0)
{
image03.Visibility = Visibility.Visible;
display3(comp);
countup++;
count--;
}
if (count > 0)
{
image04.Visibility = Visibility.Visible;
display4(comp);
countup++;
count--;
}
//This will check to see if we can even move on.. if not
the next button will not
//Be displayed.
39
if (count == 0)
{
next.Visibility = Visibility.Hidden;
}
}
//Displays stuff in picture box one and label1
private void display1(allCategory c)
{
Debug.WriteLine("Display1 "+countup);
image02.Visibility = Visibility.Hidden;
label2.Visibility = Visibility.Hidden;
price2.Visibility = Visibility.Hidden;
buy2.Visibility = Visibility.Hidden;
star2.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
image03.Visibility = Visibility.Hidden;
label3.Visibility = Visibility.Hidden;
price3.Visibility = Visibility.Hidden;
buy3.Visibility = Visibility.Hidden;
star3.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
image04.Visibility = Visibility.Hidden;
label4.Visibility = Visibility.Hidden;
price4.Visibility = Visibility.Hidden;
buy4.Visibility = Visibility.Hidden;
star4.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
//Item Name.
label1.Content = c.getName();
40
//Fix This.
BitmapImage bb = new BitmapImage();
bb.BeginInit();
bb.UriSource = new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG");
bb.EndInit();
star1.Source = bb;
price1.Content = Convert.ToString("$" + c.getPrice());
}
if (c.getRating() == 0)
{
star2.Source = new BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
}
else if (c.getRating() == 1)
{
star2.Source = new BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
41
}
else
{
if (c.getRating() == 2)
star2.Source = new
BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
}
else
if (c.getRating() == 3)
{
star2.Source = new
BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
}
if (c.getRating() == 4)
{
star2.Source = new
BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
}
if (c.getRating() == 5)
{
star2.Source =
new BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
}
42
label3.Visibility = Visibility.Visible;
price3.Visibility = Visibility.Visible;
buy3.Visibility = Visibility.Visible;
star3.Visibility = Visibility.Visible;
image03.Visibility = Visibility.Visible;
border2.Visibility = Visibility.Visible;
//Item Name.
label3.Content = c.getName();
//Fix This.
BitmapImage bb = new BitmapImage();
bb.BeginInit();
bb.UriSource = new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG");
bb.EndInit();
star3.Source = bb;
price3.Content = Convert.ToString("$"+c.getPrice());
}
private void display4(allCategory c)
{
Debug.WriteLine("Display4 " + countup);
label4.Visibility = Visibility.Visible;
price4.Visibility = Visibility.Visible;
buy4.Visibility = Visibility.Visible;
star4.Visibility = Visibility.Visible;
image04.Visibility = Visibility.Visible;
border2.Visibility = Visibility.Visible;
43
//Finds the object and sets its properties (price, name,
etc).
c.getArrayListItem(countup);
object4 = c.getObject();
image04.Source = new BitmapImage(new Uri(c.getImage()));
//Item Name.
label4.Content = c.getName();
//Fix This.
BitmapImage bb = new BitmapImage();
bb.BeginInit();
bb.UriSource = new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG");
bb.EndInit();
star4.Source = bb;
price4.Content = Convert.ToString("$" + c.getPrice());
44
display1(comp);
countup++;
ccc++;
count--;
if (count > 0)
{
display2(comp);
countup++;
count--;
ccc++;
if (count <= 0) { next.Visibility =
Visibility.Hidden; }
}
if (count > 0)
{
display3(comp);
countup++;
count--;
ccc++;
if (count <= 0) { next.Visibility =
Visibility.Hidden; }
}
if (count > 0)
{
display4(comp);
countup++;
count--;
ccc++;
if (count <= 0) { next.Visibility =
Visibility.Hidden; }
}
if (count <= 0)
{
45
next.Visibility = Visibility.Hidden;
nextbutton = false;
}
if (ccc == 1) {
image02.Visibility = Visibility.Hidden;
label2.Visibility = Visibility.Hidden;
price2.Visibility = Visibility.Hidden;
buy2.Visibility = Visibility.Hidden;
star2.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
}
}
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2(w5,kart,object1);
w2.Show();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
w4 = new Window4(this, w5,c);
w4.Show();
//w5.Show();
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
int num = 200;
for (int i=0;i<5;i++){
Thread.Sleep(1000);
num =+ 200;
image01.Width = num;
}
}
private void cart_Click(object sender, RoutedEventArgs e)
{
kart.Show();
}
46
if ((String)name == item) {
all.getArrayListItem(counter3);
object1 = all.getObject();
47
image01.Source = new BitmapImage(new
Uri(all.getImage()));
Debug.WriteLine("test search");
Debug.WriteLine(counter3++);
//Item Name.
label1.Content = all.getName();
image02.Visibility = Visibility.Hidden;
label2.Visibility = Visibility.Hidden;
price2.Visibility = Visibility.Hidden;
buy2.Visibility = Visibility.Hidden;
star2.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
image03.Visibility = Visibility.Hidden;
label3.Visibility = Visibility.Hidden;
price3.Visibility = Visibility.Hidden;
buy3.Visibility = Visibility.Hidden;
star3.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
image04.Visibility = Visibility.Hidden;
label4.Visibility = Visibility.Hidden;
price4.Visibility = Visibility.Hidden;
buy4.Visibility = Visibility.Hidden;
star4.Visibility = Visibility.Hidden;
border2.Visibility = Visibility.Hidden;
}
counter3++;
}
}
private void Button_Click_6(object sender, RoutedEventArgs e)
{
displayStuff(all);
}
private void Button_Click_7(object sender, RoutedEventArgs e)
{
displayStuff(electronicComp);
}
48
}
}
Window2
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window2.xaml
/// </summary>
public partial class Window2 : Window
{
Window5 w5;
Cart kart;
allInterface objectItem;
public Window2(Window5 w5, Cart kart,
WpfApplication3.allInterface objectItem)
{
InitializeComponent();
this.w5 = w5;
this.kart = kart;
this.objectItem=objectItem;
BitmapImage b = new BitmapImage();
49
b.BeginInit();
b.UriSource = new Uri(objectItem.getImage());
b.EndInit();
// ... Get Image reference from sender.
// var image = sender as Image;
// ... Assign Source.
item.Source = b;
name.Content = objectItem.getName();
desc.Content = objectItem.getDesc();
rating.Source=new BitmapImage(new
Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG"));
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Window3 w3 = new Window3(this,w5,objectItem);
w3.Show();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
kart.createItem(objectItem,w5);
//kart.displayitem1();
}
private void TextBox_TextChanged(object sender,
TextChangedEventArgs e)
{
}
}
}
Window3
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
50
using
using
using
using
using
using
using
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window3.xaml
/// </summary>
public partial class Window3 : Window
{
public static PayPal p;
public static cc c;
public static string var;
public Window2 w2;
public Window5 w5;
allInterface objectItem;
public Window3(Window2 w2, Window5 w5, allInterface objectItem)
{
InitializeComponent();
this.w2 = w2;
this.w5 = w5;
this.objectItem = objectItem;
}
51
this.ww2=ww2;
this.objectItem = objectItem;
}
public void pay(){
var="paypal";
Debug.WriteLine("Paypal");
p = new PayPal(ww5,ww2,objectItem);
p.Show();
}
52
public Context(Strategy strategy)
{
this.strategy = strategy;
}
public void executeStrategy()
{
strategy.pay();
}
public void pay() { }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Context context1 = new Context(new
creditcard(w5,w2,objectItem));
context1.executeStrategy();
// w5.order1.Content = w2.objectItem.getName();
// w5.addItem(w2.objectItem.getImage(),
w2.objectItem.getName());
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Context context1 = new Context(new paypal(w5,w2,objectItem));
context1.executeStrategy();
// w5.addViewCount();
// w5.addItem(w2.objectItem.getImage(),
w2.objectItem.getName());
// w5.item1.Content = w1.object1.getName();
w5.payment1.Content = "Paypal";
}
}
}
Window4
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
53
using
using
using
using
using
using
using
using
using
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window4.xaml
/// </summary>
public partial class Window4 : Window
{
Window6 w6;
Window5 w5;
Window1 w1;
public Customer c;
String firstName, lastName, address, state, zipCode;
public Window4(Window1 w1,Window5 w5, Customer c)
{
InitializeComponent();
this.w5 = w5;
this.w1 = w1;
this.c=c;
l1.Content= "First Name:
"+c.getFirstName();
l2.Content = "Last Name:
" + c.getLastName();
l3.Content = "Address:
" + c.getAddress();
l4.Content = "State:
" + c.getState();
l5.Content = "Zip Code:
" + c.getZip();
w6 = new Window6(c,l1,l2,l3,l4,l5);
this.c.getFirstName();
this.lastName=c.getLastName();
this.address= c.getAddress();
this.state=c.getState();
this.zipCode=c.getZip();
54
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window5.xaml
/// </summary>
public partial class Window5 : Window
{
private static Window5 inst;
int viewCount=0;
public static Window5 getWindow
{
get
{
if (inst == null)
inst = new Window5();
return inst;
55
}
}
public Window5()
{
InitializeComponent();
item1.Visibility
item2.Visibility
item3.Visibility
item4.Visibility
=
=
=
=
Visibility.Hidden;
Visibility.Hidden;
Visibility.Hidden;
Visibility.Hidden;
56
if (viewCount == 2)
{
item3.Visibility = Visibility.Visible;
itemimage3.Source = new BitmapImage(new Uri(image));
item3.Content = item;
}
if (viewCount == 3)
{
item4.Visibility = Visibility.Visible;
itemimage4.Source = new BitmapImage(new Uri(image));
item4.Content = item;
}
viewCount++;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.Hide();
}
}
}
Window6
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows;
System.Windows.Controls;
System.Windows.Data;
System.Windows.Documents;
System.Windows.Input;
System.Windows.Media;
System.Windows.Media.Imaging;
System.Windows.Shapes;
/*MVC PATTERN
57
* */
namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window6.xaml
/// </summary>
public partial class Window6 : Window
{
Customer c;
mvcController mvc;
View v;
Label l1,l2,l3,l4,l5;
public Window6(Customer c, Label l1,Label l2, Label l3, Label
l4, Label l5)
{
InitializeComponent();
this.l1 = l1;
//
this.w4 = w4;
this.c=c;
changeT1.Text = c.getFirstName();
changeT2.Text = c.getLastName();
changeT3.Text = c.getAddress();
changeT4.Text = c.getState();
changeT5.Text = c.getZip();
this.l2 = l2;
this.l3 = l3;
this.l4 = l4;
this.l5 = l5;
v = new View();
mvc = new mvcController(c, v,l1,l2,l3,l4,l5);
mvc.setfName(changeT1.Text);
mvc.setlName(changeT2.Text);
58
mvc.setAddress(changeT3.Text);
mvc.setState(changeT4.Text);
mvc.setZip(changeT5.Text);
mvc.updateView();
}
public class mvcController
{
Customer c;
View view;
Label l1,l2,l3,l4,l5;
public mvcController(Customer c, View view, Label l1,
Label l2, Label l3, Label l4, Label l5)
{
this.view = view;
this.c = c;
this.l1= l1;
this.l2= l2;
this.l3= l3;
this.l4= l4;
this.l5= l5;
}
public void setfName(String fname)
{
c.setFirstName(fname);
}
public void setlName(String lname)
{
c.setLastName(lname);
}
public void setAddress(String Address)
{
c.setAddress(Address);
}
public void setState(String state)
{
c.setState(state);
}
public void setZip(String zip)
{
c.setZip(zip);
}
public void updateView()
59
{
view.printCustomer(l1,l2,l3,l4,l5,c.getFirstName(),
c.getLastName(), c.getAddress(), c.getState(), c.getZip());
}
}
public class View
{
public void printCustomer(Label l1,Label l2, Label l3,
Label l4, Label l5,String firstName, String lastName, String address,
String state, String zip)
{
l1.Content = "First Name: "+firstName;
l2.Content = "Last Name: " + lastName;
l3.Content = "Address: " + address;
l4.Content = "State: " + state;
l5.Content = "Zip Code: " + zip;
}
}
}
}
UML
60
Design Patterns
Singleton Pattern
61
Adapter Pattern
Strategy Pattern
62
Iterator Pattern
Command Pattern
63
MVC Pattern
Sequence Diagrams
64
Adapter
allCategory
allCategory.NameIterator
65
allInterface
Books
Cart
66
67
Cart.cancelItem
Cart.item
Cart.Order
68
Cart.orderer
Cart.OrderItem
cc
69
Cleaning
Clothing
Customer
70
Electronics
Iterator
71
Kitchen
otherInterface
72
Paypal
Window1
73
74
75
76
Window2
Window3
Window3.Context
77
Window3.creditcard
Window3.paypal
Window3.Strategy
78
Window4
Window5
79
Window6
Window6.mvcController
Window6.View
80
Use Cases
81
82
This Use Case deals with the browsing and searching of items on Shopazon.
83
5. If a shopper sees an item he/she fancies, this item can be added to their
cart.
Postcondition(s): A shopper may browse and search items, then add items to a cart.
Use Case 3: Checking Out
This Use Case deals with how a Shopazon shopper checks out items in Shopazon.
Actor(s): Registered online shopper, Shopazon authentication, Credit Payment
Service, PayPal
Precondition(s): The online shopper is registered with Shopazon and adds items to
their cart and/or has items they wish to directly order.
Basic Flow:
1. Shopper clicks View Details button.
2. Shopper can either select Order button or Add to Cart button.
3. If Order is selected:
84
85
This Use Case deals with a registered Shopazon user editing their account information.
Actor(s): Shopper with registered Shopazon account, Shopazon authentication
Precondition(s): The online shopper has a registered Shopazon account.
Basic Flow:
1. User clicks My Account button.
2. Account window pops up that displays the users information that was
saved from when they created their account.
3. User clicks Edit Account Info button.
4. Window pops up that allows users to make changes in these fields:
a. First Name
b. Last Name
c. Address
d. State
e. Zip Code
5. User clicks Submit to accept changes to their information
6. User clicks Cancel to cancel the changes.
Postcondition(s): Shopazon system provides its users with the option to edit their
Account information. At the conclusion of this use case, a shopper can edit one or more
fields of their account info.
Use Case 1
86
User Input
System Response
Use Case 2
User Input
System Response
Once an account is create the user is taken The system reads that the Create Account
87
88
Use Case 3
User Input
System Response
89
Shopper clicks View Details button of an The system opens up a window containing
item.
the the items information.
90
91
The User can view their carts contents by The System responds by opening up a
clicking the view cart button on the main
new window that contains the list of items
window. The user can then order or delete added.
the items from the cart.
92
93
94
Use Case 4
User Input
System Response
95
The user can then click submit for the new The System will then modify the existing
information.
information stored for the user's account
with the new information submitted.
96
97
98
99
100
101
102
Presentation
103
104
105