程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA編程入門知識 >> javaDSL簡單實現示例分享

javaDSL簡單實現示例分享

編輯:JAVA編程入門知識

代碼如下:

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;
 }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved