当前位置: 移动技术网 > IT编程>开发语言>Java > javaDSL简单实现示例分享

javaDSL简单实现示例分享

2019年07月22日  | 移动技术网IT编程  | 我要评论

复制代码 代码如下:

package com.vd.dsl;
import static com.vd.dsl.graphbuilder.*;
public class main {
 public static void main(string[] args) {
  graph().edge().from("a").to("b").weigth(20.0).edge().from("b").to("c").weigth(10.0).printgraph();
 }
}

复制代码 代码如下:

package com.vd.dsl;

public class edge {
 private vertex fromvertex;
 private vertex tovertex;
 public vertex getfromvertex() {
  return fromvertex;
 }
 public void setfromvertex(vertex fromvertex) {
  this.fromvertex = fromvertex;
 }
 public vertex gettovertex() {
  return tovertex;
 }
 public void settovertex(vertex tovertex) {
  this.tovertex = tovertex;
 }
 public double getweight() {
  return weight;
 }
 public void setweight(double weight) {
  this.weight = weight;
 }
 private double weight;
 public edge() {

 }
 @override
 public string tostring() {
  return fromvertex.getlabel()+ " to "+
   tovertex.getlabel() + "with weigth "+
   this.weight;
 }
}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网