I do not understand Relationships in poo

0

I am trying to carry out a poo project, but as I go from one to the other, I find it very difficult, I would like someone to help me with an explanation, I leave an image of the project thanks.

    
asked by Juan Afanador 15.09.2018 в 05:25
source

1 answer

0

The class diagram provides a view of the structure of a system without showing the dynamic nature. Each box is divided into 3 horizontal parts.

  • The upper part contains the name of the class.
  • The middle section mentions its attributes
  • The third section contains the operations or behaviors of the class.

Class diagrams can also show relationships between classes. The multiplicity of one end of an association means the number of objects of that class that is associated with the other class.

In the experience that translates uml to code does not always correspond as the diagrams were designed to abstract the system in a modeling language that everyone could understand, follow, observe; but is not exempt from doing so I'll give you an example of how to deal with and follow the design:

package javaexamples;

public class producto
{
    private String codigo;
    private int unidadesDisponibles;
    private Double precio;

    public producto(String codigo, int unidadesDisponibles, Double precio)
    {
        this.codigo = codigo;
        this.unidadesDisponibles = unidadesDisponibles;
        this.precio = precio;
    }

    public String alta()
    {
        // codigo para insertar a la base de datos      
    }

    public void baja()
    {
        // codigo para dar de baja el producto a la base de datos       
    }

    public String modificacion()
    {
        // codigo para modificar en la base de datos        
    }

    //Otros metodos que puedes incluir
}

Fragment of code based on the product class designed in UML

I hope I have helped you succeed in your development

    
answered by 15.09.2018 в 06:37