The Software which you use to generate code from class diagram was the Umbrello. Here
a snapshot of the class diagram in Umbrello:
Now generate the code from the diagram:
First of all we must create a directory in which Umbrello can save the generated code, I would recommend do it on your desktop, to access it easier.
Once you create the directory back to Umbrello, we will go to the top toolbar click Settings, Configure we will Umbrello UML Modeller ... and we click the Code Generation tab, it will display this:
They go to the Desktop or the direction you initially saved Folder and must appear that generated classes in your diagram:
; And this is the code that I generated Umbrello for each class:
Clase Grocery:
/**
import java.util.*;
/**
* Class Grocery
*/
public class Grocery {
//
// Fields
//
//
// Constructors
//
public Grocery () { };
//
// Methods
//
//
// Accessor methods
//
//
// Other methods
//
/**
*/
public void menu( )
{
}
}
Para Product:
/**
import java.util.*;
/**
* Class Product
*/
public class Product {
//
// Fields
//
public int ID;
public float price;
public int quantity;
public String description;
//
// Constructors
//
public Product () { };
//
// Methods
//
//
// Accessor methods
//
/**
* Set the value of ID
* @param newVar the new value of ID
*/
public void setID ( int newVar ) {
ID = newVar;
}
/**
* Get the value of ID
* @return the value of ID
*/
public int getID ( ) {
return ID;
}
/**
* Set the value of price
* @param newVar the new value of price
*/
public void setPrice ( float newVar ) {
price = newVar;
}
/**
* Get the value of price
* @return the value of price
*/
public float getPrice ( ) {
return price;
}
/**
* Set the value of quantity
* @param newVar the new value of quantity
*/
public void setQuantity ( int newVar ) {
quantity = newVar;
}
/**
* Get the value of quantity
* @return the value of quantity
*/
public int getQuantity ( ) {
return quantity;
}
/**
* Set the value of description
* @param newVar the new value of description
*/
public void setDescription ( String newVar ) {
description = newVar;
}
/**
* Get the value of description
* @return the value of description
*/
public String getDescription ( ) {
return description;
}
//
// Other methods
//
/**
*/
public void add( )
{
}
/**
*/
public void modify( )
{
}
/**
*/
public void delete( )
{
}
}
Para Inventory:
/**
import java.util.*;
/**
* Class Inventory
*/
public class Inventory {
//
// Fields
//
//
// Constructors
//
public Inventory () { };
//
// Methods
//
//
// Accessor methods
//
//
// Other methods
//
/**
*/
public void makelist( )
{
}
/**
*/
public void printlist( )
{
}
}
Para Purchase:
/**
import java.util.*;
/**
* Class Purchase
*/
public class Purchase extends Inventory {
//
// Fields
//
//
// Constructors
//
public Purchase () { };
//
// Methods
//
//
// Accessor methods
//
//
// Other methods
//
/**
*/
public void search( )
{
}
/**
* / public void
purchase () {
} / **
* /
public void calculate () {
}}
code that I will analyze and develop programming for my project.
0 comments:
Post a Comment