Sunday 15 September 2013

Need to make a java program to convert UML diagram to java class on netbeans -


I just want to quickly create a Java file (using Netbeans IDE 8.0) Convert two UML diagrams to Java files To do that I have already written.

Note: Class does not really work universally with all UML drawings, but it is only to work with both of them.

UML Diagram: CarUML.txt

Car ========================== == Cost: Int color: String - Creating: string + count: int ================== CAR (int cost) ========== =========

and PetMLTX

  abdomen ================= ================================================== ========================== String - Age: int =================== Pet (name of string) =======================  

I just need a file that outputs the following to them: < / P>

Pet.java

  Package UMLconv; Public square pet {private string species; The name of the private string; Personal gaps ages; Public Pet (name of string) {this.name = name; }}  

More cars. Java

  package UMLCon; Public class car {personalized cost; Private string color; Private string make; Public int count; Public car (int cost) {this.cost = cost; }}  

I currently have this:

  import java.util.Scanner; Public class CodeFromSseudo {public static zero main (string [] algs) {scanner scan = new scanner (codeformsdoco class.rss rsssststream ("car UMLtxt"); // scanner scan = new scanner (codeframusUDA.clash.getRSOSSstream ("PetUMLTXT"); String line; String [] word; While (scan.hasNextLine ()) {line = scan.next (); System.out.printf ("public square% s {\ n", line); Scan.nextLine (); Scan.nextLine (); (For int i = 0; i  

What is missing now? Thank you

Basically you are trying to write a code generator. I am the chief architect in Batman - a company offering a tool to make a generator generator

There are tools available for this job but you can do it with scratch. Your beginning o.k. You are reading in your input and you are trying to get the output directly. Rather than approach this one step, you may want to split your code into several parts:

  1. Reading related parts and classes and properties and related Java class structure jclass / jattributes / Joperations
  2. It is necessary to make any modifications (in your case this step may be unnecessary because all your class and attribute names are valid)
  3. Creating Java code from the structure

From this point of view you see your limited input May not be far away - you only currently have visibility name and type properties, but for example, no document, as an exercise, it is OK. There may be some signs here that you get a signal of how to proceed:

  / ** * I represent a Java class with its attribute * / public class JClass {public string name; Public string documentation; // class JTT needs to be defined with // visibility, name, type and documentation fields Public list & lt; JAttribute & gt; a quality (); // Make a similar contact with the public list & lt; Jupiter & gt; Operation (); Public string asJavaCode {string code = ""; Code + = "/ ** code + =" * "+ documentation; code + =" * / "; code + =" public class "+ name +" {\ n "; code + =" // member "; ( J Specialty attribute: Properties) {Code + = "//" + attribute.documentation; code + = attribute.visibility + "+ + attribute.type +" "+ attribute.name +"; "//" Joints Setting and Setters Here you are viewing the fit) // add operation code code = = "}";} // add code to add attributes}  

No comments:

Post a Comment