Property of Penn Engineering
How Do We Convert a UML
Diagram to Code?
Copyright By PowCoder代写 加微信 powcoder
Property of Penn Engineering
•Domain Modeling: Use the specification to identify
the classes, their attributes and operations, and their
relationships
•UML Class Diagrams: represent the design in a
visual manner
Review: Design Process
Property of Penn Engineering
Property of Penn Engineering
public abstract class BankAccount {
protected double balance;
protected String accountId;
protected Customer accountOwner;
//NOT SHOWN: constructors, get/set methods
public void open(double intialBalance) {…}
public double deposit(double amount) {…}
public double withdraw(double amount) {…}
BankAccount.java
Property of Penn Engineering
public abstract class BankAccount {
protected double balance;
protected String accountId;
protected Customer accountOwner;
//NOT SHOWN: constructors, get/set methods
public void open(double intialBalance) {…}
public double deposit(double amount) {…}
public double withdraw(double amount) {…}
BankAccount.java
Property of Penn Engineering
public abstract class BankAccount {
protected double balance;
protected String accountId;
protected Customer accountOwner;
//NOT SHOWN: constructors, get/set methods
public void open(double intialBalance) {…}
public double deposit(double amount) {…}
public double withdraw(double amount) {…}
BankAccount.java
Property of Penn Engineering
public abstract class BankAccount {
protected double balance;
protected String accountId;
protected Customer accountOwner;
//NOT SHOWN: constructors, get/set methods
public void open(double intialBalance) {…}
public double deposit(double amount) {…}
public double withdraw(double amount) {…}
BankAccount.java
Property of Penn Engineering
public class SavingsAccount extends BankAccount {
protected double interestRate;
//NOT SHOWN: constructors, get/set methods
public double applyInterest() {…}
SavingsAccount.java
Property of Penn Engineering
public class SavingsAccount extends BankAccount {
protected double interestRate;
//NOT SHOWN: constructors, get/set methods
public double applyInterest() {…}
SavingsAccount.java
Property of Penn Engineering
public class Person{
protected String name;
protected String[] emailAddress;
protected Address homeAddress:
protected Address workAddress;
//NOT SHOWN: constructors, get/set methods
Customer.java, Person.java
public class Customer extends Person{
protected String customerId;
//NOT SHOWN: constructors, get/set methods
Property of Penn Engineering
public class Person{
protected String name;
protected String[] emailAddress;
protected Address homeAddress:
protected Address workAddress;
//NOT SHOWN: constructors, get/set methods
Customer.java, Person.java
public class Customer extends Person{
protected String customerId;
//NOT SHOWN: constructors, get/set methods
Property of Penn Engineering
Property of Penn Engineering
• Detailed UML Class Diagrams allow us to show details of
classes in our design: attributes, operations, relationships
• Can easily be converted to Java
• Attributes à Fields
• Named relationships à Fields
• Operations à Methods
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com