Download presentation
Presentation is loading. Please wait.
1
Static vs. Dynamic Relationships CIS 480 System Analysis and Design
2
Domain Classes (business domain) 11..* Static Association or (problem domain)
3
Design Classes (solution domain)
4
Order Class public class Order { private OrderLine[] orderline = new OrderLine[5]; private int orderNumber; public Order(int o) { orderNumber = o; for (int i = 0; i < 5; i++) orderline[i] = null; } public void addOrderLine(int line, string d, double q, double p) { orderline[line] = new OrderLine(this, d, q, p); } public string[] getLines() { string[] returnS = new string[3]; int i = 0; while (orderline[i] != null) { returnS[i] = orderline[i].DESCRIPTION + ", " + orderline[i].QUANTITY + ", " + orderline[i].PRICE; i++; } return returnS; }
5
OrderLine Class public class OrderLine { private string description; private double quantity; private double price; private Order order; public OrderLine(Order o, string d, double q, double p) { order = o; description = d; quantity = q; price = p; } public string DESCRIPTION { get { return description;} } public double QUANTITY { get { return quantity; } set { quantity = value; } } public double PRICE { get {return price; } set { price = value; } }
6
Form1 Class { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button btCreateOrder; private System.Windows.Forms.Button btOrderLines; private System.Windows.Forms.TextBox txtOrder; private System.Windows.Forms.TextBox txtOrderLines; private System.Windows.Forms.Button btListLines; private System.Windows.Forms.ListBox lstOrderLines; private System.Windows.Forms.Label lblStatic; private System.Windows.Forms.Label lblColumns; private System.Windows.Forms.Label lblLine; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; private System.Windows.Forms.Label lblStaticDesc; private System.Windows.Forms.Label lblDynamicDesc; private Order order; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // }
7
Form1 Class [ STAThread] static void Main() { Application.Run(new Form1()); } private void createOrderClick(object sender, System.EventArgs e) { order = new Order(2345); txtOrder.Text = "Order 2345 created"; } private void createOrderLinesClick(object sender, System.EventArgs e) { order.addOrderLine(0, "Boxes", 12, 1.25); order.addOrderLine(1, "Chairs", 2, 45.78); order.addOrderLine(2, "Table", 1, 167.00); txtOrderLines.Text = "3 order lines created"; } private void listOrderLinesClick(object sender, System.EventArgs e) { string[] list = new string[5]; list = order.getLines(); lstOrderLines.Items.AddRange(list); } private void lblDynamicDesc_Click(object sender, System.EventArgs e) { }
8
User Interface
9
Dynamic Actions During Execution
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.