Sie sind auf Seite 1von 106

Shopazon

Shannon Sergeant, Stephen Daniel, and Christopher Hanson


Object Oriented Design Project Team Report

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>();

public Iterator getIterator()


{
return new NameIterator(abc);
}
private class NameIterator : Iterator

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()
{
}

//So we can get the product.


allInterface object1;

//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;

public void addItemArray(Item item) {


itemList.Add(item);
}

12

public void createItem(allInterface objectItem, Window5 w5)


{
i = new Item(objectItem.getName(),
objectItem.getImage(),w5,cancelItems);
addItemArray(i);
counter2++;
displayitem1();
}
public void displayitem1()
{
Item item;
if (countItemArray==0){
item = itemList[0];
itemimage1.Source = new BitmapImage(new
Uri(item.getImage()));
itemimage1.Visibility = Visibility.Visible;
order1.Visibility = Visibility.Visible;
delete1.Visibility = Visibility.Visible;
}
else if (countItemArray == 1)
{
item = itemList[1];
itemimage2.Source = new BitmapImage(new
Uri(item.getImage()));
itemimage2.Visibility = Visibility.Visible;
order2.Visibility = Visibility.Visible;
delete2.Visibility = Visibility.Visible;
}
else if (countItemArray == 2)
{
item = itemList[2];
itemimage3.Source = new BitmapImage(new
Uri(item.getImage()));
itemimage3.Visibility = Visibility.Visible;
order3.Visibility = Visibility.Visible;
delete3.Visibility = Visibility.Visible;
}
else if (countItemArray == 3)
{

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++;
}

public void recursive() {


int intt = itemList.Count();
itemList2.Clear();
Debug.WriteLine(intt);
for (int iii = 0; iii < intt; iii++) {
if (itemList[iii]!=null){
itemList2.Add(itemList[iii]);
counterr++;
}
}
itemList.Clear();
for (int iii = 0; iii < itemList2.Count(); iii++) {
itemList.Add(itemList2[iii]);
}

//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";
}
}

public interface Order


{
void execute();
}

public class Item {


public string image;
public string name;
Window5 w5;
List<String> cancelItems;
public Item(string name, string image,Window5 w5,List<String>
cancelItems)
{
this.image = image;
this.name = name;

15
this.w5 = w5;
this.cancelItems = cancelItems;
}

void setImage(string image){


}
void setName(string name){
}
public String getImage()
{
return image;
}
public void addToOrder(){
//
w5.addViewCount();
w5.addItem(image, name);
}
public void cancel(){
cancelItems.Add(name);
}

}
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();
}
}

public class CancelItem:Order {


private Item item;
public CancelItem(Item item){
this.item = item;
}
public void execute() {
item.cancel();
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Item i = itemList[0];
oi1 = new OrderItem(i);
broker.takeOrder(oi1);

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

private void delete4_Click(object sender, RoutedEventArgs e)


{
Item i = itemList[3];
ci4 = new cancelItem(i);
broker.takeOrder(ci4);
i = null;
itemList[3] = i;
}

private void Button_Click_8(object sender, RoutedEventArgs e)


{
this.Hide();
}

}
}
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;

// this.Background = new ImageBrush(new BitmapImage(new


Uri("C:\\Users\\Stephen\\Pictures\\background.png")));
}
private string firstName;
public string FirstName
{

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();
}

//Once the user hits the submit button a customer will be


created. The customer takes in the
//arguments from the textboxes (TextBox1.Text... and so
forth). This will be our customer information
//That will travel through all the forms.
private void button1_Click(object sender, EventArgs e)
{

Customer customer = new Customer(firstName, "ello",


"ello", "ello", "ello");
w1 = new Window1(customer);
//
//
//
//
//

String aaa;
String aac="HELLO";
aaa = TextBox1.Text;
Debug.WriteLine(TextBox1.Text);
customer.Name=aac;

//This is our second form, which passes the arguments of


this form (form1) and customer
//object. (I dont think we need to send this form through,
but I cannot get form3, which is
//the Account Info form to work without it... for now)
// Form2 f2 = new Form2(this,customer);
//Displays the form 2.

27
// f2.Show();
}
private void Button_Click(object sender, RoutedEventArgs e)
{

// String abc = FirstName.firstName;


Customer customer = new Customer(t1.Text, t2.Text,
t3.Text, t4.Text, t5.Text);
w1 = new Window1( customer);
w1.Show();
}
//Getters and Setters for the textboxes.
}
//Customer class. Very basic for now and maybe forever.
public class Customer
{
String firstName, lastName, address, state, zip;
public Customer(String firstName, String lastName, String
address, String state, String zip)
{
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.state = state;
this.zip = zip;
}

public
public
public
public
public

String
String
String
String
String

getFirstName() { return firstName; }


getLastName() { return lastName; }
getAddress() { return address; }
getState() { return state; }
getZip() { return zip; }

public void setFirstName(string arg) { firstName=arg; }


public void setLastName(string arg) { lastName = arg; }
public void setAddress(string arg) { address = arg; }

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;
}

private void Button_Click(object sender, RoutedEventArgs e)


{
w5.addItem(objectItem.getImage(), objectItem.getName());
}

}
}
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;

/*Adapter and Singleton and Iterator*/


namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
//Global variables to be used to mainly keep up with how many
object are left to display
//on screen... so for example we have two slots for objects on
screen for the user to choose right?
//Well what if we only have one more item left to display?
This will keep prevent the second
//box from showing up and also controls our next and prev
buttons (for example, if there are no
//more object to access then we need to hide the next button).
//NOTE
public
public
public
public
public
public

COUNTERS ARE NOT 100% FUNCTIONAL RIGHT NOW.


static int counter = 0;
static int counter2 = 0;
static int countNext = 0;
static int countup = 0;
static int count = 0;
static int counter3 = 0;

// public static String imageGlobal ;


// public static String nameGlobal count ;
// public static String desc count ;
//These objects right now are the same in terms of arguments,
we can however make
//them different... if we want.

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;

//Our categories objects.


//Put all object in this.
allCategory all = new allCategory();
allCategory booksComp = new allCategory();
allCategory electronicComp = new allCategory();
allCategory cleaningCategory = new allCategory();
allCategory KitchenCategory = new allCategory();
allCategory clothingCategory = new allCategory();

35

//Dynamic Comp
public allCategory comp;
//Pass on Customer
Customer c;
//Window stuff/SINGLETON
public Window5 w5 = Window5.getWindow;
Window4 w4;
Cart kart;

//Boolean for nextbutton


public Boolean nextbutton = true;

//Composite composite = new Composite();


public Window1()
{
InitializeComponent();
}

public Window1(Customer c)
{
InitializeComponent();
kart = new Cart();
this.c = c;

//Adding our objects to our categories


cleaningCategory.addObject(broom);
cleaningCategory.addObject(vac);
cleaningCategory.addObject(mop);
cleaningCategory.addObject(duster);
//electronicComp.addObject(electronic1);
//This takes the knife and turns it into comp...
// kitchenAdapter.addObject( new Composite(knife));
//kitchenAdapter.addObject(new Composite(pans));

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
//

Debug.WriteLine("Count ="+ count);

//Count is to find how many items we have. This is so we


cant display item 5

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;

//Finds the object and sets its properties (price, name,


etc).
c.getArrayListItem(countup);
object1 = c.getObject();
image01.Source = new BitmapImage(new Uri(c.getImage()));

//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());
}

//Samething but for picturebox2 and label2


private void display2(allCategory c)
{
Debug.WriteLine("Display2 " + countup);
label2.Visibility = Visibility.Visible;
price2.Visibility = Visibility.Visible;
buy2.Visibility = Visibility.Visible;
star2.Visibility = Visibility.Visible;
image02.Visibility = Visibility.Visible;
border2.Visibility = Visibility.Visible;
c.getArrayListItem(countup);
object2 = c.getObject();
image02.Source = new BitmapImage(new Uri(c.getImage()));

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));
}

star2.Source = new BitmapImage(new


Uri("pack://application:,,,/WpfApplication3;component/Resources/4star.
PNG", UriKind.Absolute));
//test.Source = new Uri(vac);
label2.Content = c.getName();
price2.Content = Convert.ToString("$" + c.getPrice());
}

private void display3(allCategory c)


{
Debug.WriteLine("Display3 " + countup);

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;

//Finds the object and sets its properties (price, name,


etc).
c.getArrayListItem(countup);
object3 = c.getObject();
image03.Source = new BitmapImage(new Uri(c.getImage()));

//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());

private void Button_Click(object sender, RoutedEventArgs e)


{
displayStuff(cleaningCategory);
}

private void next_Click(object sender, RoutedEventArgs e)


{
{
int ccc = 0;

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

private void buy2_Click(object sender, RoutedEventArgs e)


{
Window2 w2 = new Window2( w5, kart, object2);
w2.Show();
}
private void buy3_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2(w5, kart, object3);
w2.Show();
}
private void buy4_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2(w5, kart, object4);
w2.Show();
}
private void Button_Click_4(object sender, RoutedEventArgs e)
{
displayStuff(booksComp);
}

private void Button_Click_5(object sender, RoutedEventArgs e)


{
displayStuff(KitchenCategory);
}
private void Search_Click(object sender, RoutedEventArgs e)
{
counter3 = 0;
String item=searchBox.Text;
for (Iterator iter = all.getIterator(); iter.hasNext(); )
{
String name = (String)iter.next();
Console.WriteLine("Name : " + name);

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

private void Button_Click_8(object sender, RoutedEventArgs e)


{
displayStuff(clothingCategory);
}

}
}
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;
}

public interface Strategy{


void pay();}
public class paypal : Strategy {
public Window5 ww5;
public Window2 ww2;
allInterface objectItem;
public paypal(Window5 ww5, Window2 ww2, allInterface
objectItem)
{
this.ww5=ww5;

51
this.ww2=ww2;
this.objectItem = objectItem;
}
public void pay(){
var="paypal";
Debug.WriteLine("Paypal");
p = new PayPal(ww5,ww2,objectItem);
p.Show();
}

internal void show()


{
throw new NotImplementedException();
}
}
public class creditcard : Strategy
{
Window5 ww5;
Window2 ww2;
allInterface objectItem;
public creditcard(Window5 ww5, Window2 ww2, allInterface
objectItem)
{
this.ww5 = ww5;
this.ww2 = ww2;
this.objectItem = objectItem;
}
public void pay()
{
var = "creditcard";
Debug.WriteLine("CreditCard");
c = new cc(ww5,ww2,objectItem);
c.Show();
}
}
public class Context
{
Strategy strategy;

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

private void Button_Click(object sender, RoutedEventArgs e)


{
w5.Visibility = Visibility.Visible;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
w6.Show();
}
}
}
Window 5

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;

private void Button_Click(object sender, RoutedEventArgs e)


{
this.Visibility = Visibility.Hidden;
}

public void addViewCount() {


//viewCount++;
}

public void addItem(string image, string item)


{
if (viewCount == 0) {
item1.Visibility = Visibility.Visible;
itemimage1.Source = new BitmapImage(new Uri(image));
item1.Content = item;
}
if (viewCount == 1)
{
item2.Visibility = Visibility.Visible;
itemimage2.Source = new BitmapImage(new Uri(image));
item2.Content = item;
}

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);

private void Button_Click(object sender, RoutedEventArgs e)


{

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

Visual Representation of Shopazon Use Cases.


Use Case 1: Registering for Shopazon Account
This Use Case deals with the registration of an online shopper in the Shopazon system.
Actor(s): Unregistered online shopper, Shopazon authentication
Precondition(s): The online shopper has not previously registered an account with
Shopazon.
Basic Flow:
1. The shopper enters his/her information into the Shopazon interface.
a. First Name
b. Last Name
c. Address
d. State
e. Zip Code
2. The shopper clicks the Create Account button.
Postcondition(s): Shopazon authenticates the previously unregistered online
shopper as a registered shopper who is able to view items
Use Case 2: Viewing Items

82

This Use Case deals with the browsing and searching of items on Shopazon.

Actor(s): Registered online shopper, Shopazon authentication


Precondition(s): The online shopper has registered with a Shopazon account, and
thus has the authentication necessary to browse, search, view product ratings, and add
items to shopping cart.
Basic Flow:
1. Shopazon opens a window that displays all products from all categories.
2. A Shopazon shopper can search for an item in the search bar. Shopazon
displays the results of the search query.
3. A shopper can browse items by various categories including:
a. Kitchen
b. Cleaning
c. Books
d. Electronics
e. Clothes
4. Shopazon displays Product Rating for all its products. A shopper can view
a star rating, and see a Critics Review by clicking View Details.

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

a. Shopper can either select to pay with CreditCard or pay


with PayPal
b. If shopper selects CreditCard:
i. A window pops up that prompts the user to
enter Credit Card information: Card Number, Name on Card,
Expiration Date
ii. Shopper clicks Submit
iii. To verify that the item has been purchased and
ordered, user can select My Account button then click View
Orders
iv. Purchased Item should appear in Orders list
c. If shopper selects PayPal:
i. A window pops up that prompts the user to
enter PayPal login information
ii. Shopper clicks Login
iii. To verify that the item has been purchased and
ordered, user can select My Account button then click View
Orders
iv. Purchased Item should appear in Orders list
4. If Add to Cart is selected:
a. User can continue their Shopazon shopping and add more
items as they see fit.
b. User can view carts contents and/or update the cart with
new items
c. Once user has concluded their shopping, they may visit their
cart to either click Delete by the item to delete it, or click Order by the
item to order the item.
d. To verify that the item has been ordered, user can select My
Account button and then click View Orders
e. The items the shopper ordered should be appear in the
Orders list
Postcondition(s): Shopazon shopper has added items to cart, or bought them
directly from View Details. Depending upon the chosen payment strategy, PayPal or a
Credit Payment service interacts with the Shopazon system to process the shoppers
orders.

Use Case 4: Editing Shopazon Account Information

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.

White Box Testing

Use Case 1

86

User Input

System Response

The user will enter in the appropriate


fields to register for the account and
clicks create account.

The System will then store the


information recorded and send the user to
the next window.

Use Case 2
User Input

System Response

Once an account is create the user is taken The system reads that the Create Account

87

to the window where they can browse for


items.

Button has been clicked a window with all


items will appear.

A user can search for a given item by


typing in an item in the search bar.

The system will take the item and check


for any item names that have a partial or
complete match and bring up those items
for the user to see.

A user can browse for items by clicking on


the different category tabs.

The system will then alternate the data in


the window based on the tab selected.

88

A user can click on an item's View


Details icon to check a review and rating
of a particular item.

The system will then load up a window


that contains the items information.

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.

The shopper can click the Order button


to pay for the item.

The system responds by bringing up a


payment type window when the button is
selected.

The user can choose to select Credit Card


or Paypal for payment type.

The system responds by displaying a new


window for each payment type.

90

If Credit Card is chosen,The user can fill


out the credit card information and click
Submit.

When either Submit or Login is clicked,


the system will send the items to the
users Order list.

If Paypal is chosen, the user can put in


their username and password and then
click Login

Alternatively, a user can choose to click

The System responds by placing the item

91

Add to Cart if they wish to continue


shopping.

into a List for later use.

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

The user can click order to order an item

The System will add the item to the


Orders List.

The user can choose to delete an item.

The System will delete the item from the


list.

93

The user can view the order list by


clicking the View Account button on the
main window.

The System will open a new window


containing the Account Information.

The user can click the View Orders


button to view the items ordered.

The System brings up a new window that


contains the list of ordered items.

94

Use Case 4
User Input

System Response

The User can view Account Information


by clicking the My Account button on
the main window.

The System will bring up a new window


that contains the users Account
Information.

The user can edit the Information by


clicking Edit Account Info.

The System brings up a new window for


the user to enter in new information.

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.

Black Box Testing

96

The opening the user sees in order to


create an Account.

The main window where the user can


view items. The All Category is the
default.

The Cleaning Category

97

The Kitchen Category

The Electronics Category

The Books Category

98

The Clothes Category

When a user views item details

User clicks order

99

User pays by Credit Card

User pays by Paypal

100

User views account

User views cart

101

User deletes from cart

User Views Orders

User Edits Account

102

Presentation

103

104

105

Das könnte Ihnen auch gefallen