-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnode.java
More file actions
68 lines (57 loc) · 1.37 KB
/
node.java
File metadata and controls
68 lines (57 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
public class node
{
private int traffic; //thte traffic intensity will vary dynamically
private int distance; //the distance is fixed and is expressed in metres
private int tvertex; //indicates the terminal vertex
private int speed; //measure of how fast will it take to reach this node
private node next;
public node(int distance, int traffic, int tvertex) //constructor
{
this.traffic =traffic;
this.distance =distance;
this.speed = distance/traffic;
this.tvertex =tvertex;
this.next=null;
}
public node(int distance, int tvertex) //constructor
{
this.tvertex =tvertex;
this.distance = distance;
this.traffic =1; //default light traffic; 1-light; 2-moderate; 3-heavy
this.speed =distance;
this.next=null;
}
public int getTraffic() //getter method
{
return this.traffic;
}
public int getDistance()
{
return this.distance;
}
public int getTvertex()
{
return tvertex;
}
public node getNext()
{
return this.next;
}
public int getSpeed()
{
return this.distance/this.traffic;
}
public void setNext(node n)
{
this.next =n;
}
public void setTraffic(int t)
{
this.traffic =t;
}
public String toString()
{
return "This road has traffic intensity "+this.traffic+" and distance is "+this.distance+"m\nSpeed:"+getSpeed();
}
}