SlideShare a Scribd company logo
Mapeamento de UML -> JAVA
Como implementar Código JAVA a partir de
algumas notações UML.
// Notes will be used in the
// rest of the presentation
// to contain Java code for
// the attached UML elements
public class Course
{
Course() { }
protected void finalize()
throws Throwable {
super.finalize();
}
};
Course
Representação de notas
public class Student
{
private String name;
public void addSchedule (Schedule theSchedule; Semester forSemester) {
}
public boolean
hasPrerequisites(CourseOffering forCourseOffering) {
}
protected boolean
passed(CourseOffering theCourseOffering) {
}
}
Visibilidade para Atributos e Operações
Student
- name : String
+ addSchedule (theSchedule: Schedule, forSemester: Semester)
+ hasPrerequisites(forCourseOffering: CourseOffering) : int
# passed(theCourseOffering: CourseOffering) : int
class Student
{
private static int nextAvailID = 1;
public static int getNextAvaiIID() {
}
}
Escopo de atributos, operações e classes
Student
- nextAvailID : int = 1
+ getNextAvaiIID() : int
<<utility>>
MathPack
-randomSeed : long = 0
-pi : double = 3.14159265358979
+sin (angle : double) : double
+cos (angle : double) : double
+random() : double
import java.lang.Math;
import java.util.Random;
class MathPack
{
private static randomSeed long = 0;
private final static double pi =
3.14159265358979;
public static double sin(double angle) {
return Math.sin(angle);
}
static double cos(double angle) {
return Math.cos(angle);
}
static double random() {
return new
Random(seed).nextDouble();
}
}
void somefunction() {
. . .
myCos = MathPack.cos(90.0);
. . .
Classe utilitária
Outer
Outer::Inner
class Outer
{
public outer() { }
class Inner {
public Inner() { }
}
}
Inner Class
Schedule
Student
class Student
{
public Student() { }
private Schedule theSchedule;
}
// no need to import if in same package
class Schedule
{
public Schedule() { }
private Student theStudent ;
}
Associações
 Bi-direcional
Schedule
Student
class Student
{
public Student() { }
private Schedule theSchedule;
}
class Schedule
{
public Schedule() { }
}
Navegabilidade
 Uma direção
Professor
CourseOffering
instructor
class Professor
{
public Professor() {}
private CourseOffering theCourseOffering;
}
class CourseOffering
{
public CourseOffering() {}
private Professor instructor;
}
Regras nas associações
CourseOffering
Schedule
class Schedule
{
public Schedule() {}
private CourseOffering[] primaryCourses =
new CourseOffering[4]
}
class CourseOffering
{
public CourseOffering() {}
}
0..4 primaryCourses
Associações múltiplas
// No need to import if in the same package
class PrimaryScheduleOfferingInfo
{
public PrimaryScheduleOfferingInfo() {}
public CourseOffering get_theCourseOffering(){
return theCourseOffering;
}
public void set_theCourseOffering(CourseOffering toValue){
theCourseOffering = toValue;
}
private char get_Grade (){ return grade; }
private void set_Grade(char toValue) { grade = toValue; }
private char grade = ‘I’;
private CourseOffering theCourseOffering;
}
Classe associativa
Schedule CourseOffering
0..4
0..*
primaryCourses
PrimaryScheduleOfferingInfo
- grade: char = I
alternateCourses
0..2
0..*
0..*
Schedule CourseOffering
1
1 0..4
0..2
0..*
alternateCourses
primaryCourseOfferingInfo PrimaryScheduleOfferingInfo
- grade: char = I
Design Decisions
Course
prerequisites
0..* import java.util.Vector;
class Course
{
public Course() {}
// The unbounded multiple association
// is stored in a vector
private Vector prerequisites;
}
Associação reflexiva
Schedule
Student
class Schedule
{
public Schedule() { }
private Student theStudent;
}
0..*
1 import java.util.Vector;
class Student
{
public Student() { }
private Vector theSchedule;
}
Agregação
Schedule
Student
class Schedule
{
public Schedule() { }
private Student theStudent;
}
0..*
1
import java.util.Vector;
class Student
{
public Student() { }
private Vector theSchedule = new Vector();
}
Composição
Serializable
<<Interface>>
Schedule
<<entity>>
interface Serializable {
}
class Schedule implements Serializable {
}
Interfaces and Realizações
GroundVehicle
class Truck extends GroundVehicle
{
public float tonnage;
public void getTax() { }
}
class GroundVehicle
{
public int licenseNumber;
public void register() { }
}
+licenseNumber: int
+register()
Truck
+tonnage: float
+getTax()
Generalização
Amphibious
Vehicle
<<Interface>>
IVehicle
<<Interface>>
IWaterVehicle
Land
Vehicle
{overlapping}
class AmphibiousVehicle
extends LandVehicle
implements WaterVehicle
{
. . .
}
<<realize>>
<<realize>>
interface IWaterVehicle :
implements IVehicle
{
. . .
}
Em Java, uma classe herda somente de
uma classe, porém, ela pode implementar
várias Interfaces.
Herança Múltipla
Herança múltipla (continuação)
AmphibiousVehicle
LandVehicle
IAmphibiousVehicle
<<Interface>>
IHobby
<<Interface>>
IWaterVehicle
<<Interface>>
ILandVehicle
<<Interface>>
In Java, a class can inherit
from one superclass.
It can, however implement
multiple interfaces.
An interface can inherit
from many interfaces.
abstract class Animal
{
public abstract void talk();
}
Animal
{abstract}
Lion
+talk()
Tiger
+talk()
class Tiger extends Animal
{
public Tiger() { }
public void talk() { }
}
+talk() {abstract}
Classe Abstrata
Set
T, n:int
<<bind>>
mySetOfFloats
insert(T)
remove(T)
<float, 100>
Java does not support parameterized classes
Classe Parametrizada
package CourseCatalog;
public interface ICourseCatalog {
public CourseOfferingList
getCourseOfferings();
}
CourseCatalog
<<subsystem>>
ICourseCatalog
Subsistemas

More Related Content

PPT
6 Inheritance
PPTX
Inheritance and Interfaces
PPT
Implementation of interface9 cm604.30
PDF
Object Oriented Programming using C++ - Part 1
PDF
Object Oriented Programming using C++ - Part 2
PDF
Object Oriented Programming using C++ - Part 3
PDF
Object Oriented Programming using C++ - Part 5
PDF
Object Oriented Programming using C++ - Part 4
6 Inheritance
Inheritance and Interfaces
Implementation of interface9 cm604.30
Object Oriented Programming using C++ - Part 1
Object Oriented Programming using C++ - Part 2
Object Oriented Programming using C++ - Part 3
Object Oriented Programming using C++ - Part 5
Object Oriented Programming using C++ - Part 4

Similar to Mapeamento uml java (20)

PPTX
Refactoring - Mejorando el diseño del código existente
PPT
A Unified View of Modeling and Programming
PPT
Jar chapter 5_part_i
KEY
Domänenspezifische Sprachen mit Xtext
PDF
import school.; import school.courses.;public class Main { p.pdf
PPT
Models, Programs and Executable UML
PPTX
Unified modeling language
PPT
SDA ClassDiagram.ppt
PPTX
Unified modeling language
PDF
Starting with Main.java, where I tested everythingimport College..pdf
PPTX
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
PDF
I have an interface Peron that has firstnamestring, lastnamestring.pdf
PPT
M03 1 Structuraldiagrams
PDF
20070329 Object Oriented Programing Tips
PPT
M02 Uml Overview
PDF
Software Engineering :UML class diagrams
PPT
Introduction to UML, class diagrams, sequence diagrams
PPT
Week 10-classdiagrams.pptdddddddddddddddddddddddddddd
DOCX
COSC 2436 – PROJECT Contents TITLE ..................docx
PDF
ICSM04 Poster.ppt
Refactoring - Mejorando el diseño del código existente
A Unified View of Modeling and Programming
Jar chapter 5_part_i
Domänenspezifische Sprachen mit Xtext
import school.; import school.courses.;public class Main { p.pdf
Models, Programs and Executable UML
Unified modeling language
SDA ClassDiagram.ppt
Unified modeling language
Starting with Main.java, where I tested everythingimport College..pdf
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
I have an interface Peron that has firstnamestring, lastnamestring.pdf
M03 1 Structuraldiagrams
20070329 Object Oriented Programing Tips
M02 Uml Overview
Software Engineering :UML class diagrams
Introduction to UML, class diagrams, sequence diagrams
Week 10-classdiagrams.pptdddddddddddddddddddddddddddd
COSC 2436 – PROJECT Contents TITLE ..................docx
ICSM04 Poster.ppt
Ad

Recently uploaded (20)

PPTX
ai tools demonstartion for schools and inter college
PPTX
Transform Your Business with a Software ERP System
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
System and Network Administration Chapter 2
PPTX
assetexplorer- product-overview - presentation
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
medical staffing services at VALiNTRY
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPT
Introduction Database Management System for Course Database
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
ai tools demonstartion for schools and inter college
Transform Your Business with a Software ERP System
Operating system designcfffgfgggggggvggggggggg
System and Network Administration Chapter 2
assetexplorer- product-overview - presentation
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
medical staffing services at VALiNTRY
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
VVF-Customer-Presentation2025-Ver1.9.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Introduction Database Management System for Course Database
wealthsignaloriginal-com-DS-text-... (1).pdf
Nekopoi APK 2025 free lastest update
Understanding Forklifts - TECH EHS Solution
CHAPTER 2 - PM Management and IT Context
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Ad

Mapeamento uml java

Editor's Notes

  • #2: Appendix - UML to Java Mapping
  • #3: Appendix - UML to Java Mapping
  • #4: Appendix - UML to Java Mapping
  • #5: Appendix - UML to Java Mapping
  • #6: Appendix - UML to Java Mapping
  • #7: Appendix - UML to Java Mapping
  • #8: Appendix - UML to Java Mapping
  • #9: Appendix - UML to Java Mapping
  • #10: Appendix - UML to Java Mapping
  • #11: Appendix - UML to Java Mapping
  • #12: Appendix - UML to Java Mapping
  • #13: Appendix - UML to Java Mapping
  • #14: Appendix - UML to Java Mapping
  • #15: Appendix - UML to Java Mapping
  • #16: Appendix - UML to Java Mapping
  • #17: Appendix - UML to Java Mapping
  • #18: Appendix - UML to Java Mapping
  • #19: Appendix - UML to Java Mapping
  • #20: Appendix - UML to Java Mapping
  • #21: Appendix - UML to Java Mapping
  • #22: Appendix - UML to Java Mapping