资源简介
面向对象仿真技术相关设计作业,利用java技术实现了十字路口的车流量仿真

代码片段和文件信息
package com.traffic;
import java.awt.Image;
import java.util.Date;
import java.util.Random;
public class Car
{
private int x; //坐标
private int y;
private int width=30;
private int heigth=50;
private int type;// 小车的行驶方�?
private double v;//速度
private Image image;
private int colour; //汽车颜色 0:红色 1:蓝�?
private boolean turnRight=false;
public Car()
{ // 构�?函数
colour=new Random().nextInt(2);
type = (int) (((Math.random()) * (new Date().getTime()) * 10) % 4);
if(new Random().nextInt(4)==0)
{
turnRight=true;
}
if (type == 0) //为西-东方�?
{
x = 0;
if(turnRight)
{
y = 255+2;
}
else
{
y=230+2;
}
width=30;
heigth=20;
image=CarImage.getCar_RightImage(colour);
}
else if (type == 1) //为东-西方向;
{
x = 1500;
if(turnRight)
{
y = 180+2;
}
else
{
y=205+2;
}
width=30;
heigth=20;
image=CarImage.getCar_LeftImage(colour);
}
else if (type == 2) //为北-南方向;
{
if(turnRight)
{
x = 220+2;
}
else
{
x = 245+2;
}
y = 0;
width=20;
heigth=30;
image=CarImage.getCar_DownImage(colour);
}
else if (type == 3) //为南-北方�?
{
if(turnRight)
{
x = 295+2;
}
else
{
x = 270+2;
}
y = 1500;
width=20;
heigth=30;
image=CarImage.getCar_UpImage(colour);
}
}
public int getX()
{
return x;
}
public void setX(int x)
{
this.x = x;
}
public int getY()
{
return y;
}
public void setY(int y)
{
this.y = y;
}
public int getType()
{
return type;
}
public void setType(int type)
{
this.type = type;
if (type == 0) //为西-东方�?
{
width=30;
heigth=20;
image=CarImage.getCar_RightImage(colour);
}
else if (type == 1) //为东-西方向;
{
width=30;
heigth=20;
image=CarImage.getCar_LeftImage(colour);
}
else if (type == 2) //为北-南方向;
{
width=20;
heigth=30;
image=CarImage.getCar_DownImage(colour);
}
else if (type == 3) //为南-北方�?
{
width=20;
heigth=30;
image=CarImage.getCar_UpImage(colour);
}
}
public double getV()
{
return v;
}
public void setV(double v)
{
this.v = v;
}
public Image getImage()
{
return image;
}
public void setImage(Image image)
{
this.image = image;
}
public int getWidth()
{
return width;
}
public void setWidth(int width)
{
this.width = width;
}
public int getHeigth()
{
return heigth;
}
public void setHeigth(int heigth)
{
this.heigth = heigth;
}
public boolean isTurnRight()
{
return turnRight;
}
public void setTurnRight(boolean turnRight)
{
this.turnRight = turnRight;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-31 14:37 交通灯仿真\
文件 301 2013-12-26 13:45 交通灯仿真\.classpath
文件 396 2013-12-26 13:45 交通灯仿真\.project
目录 0 2013-12-31 14:37 交通灯仿真\.settings\
文件 265 2013-12-28 22:38 交通灯仿真\.settings\org.eclipse.core.resources.prefs
文件 629 2013-12-26 13:45 交通灯仿真\.settings\org.eclipse.jdt.core.prefs
目录 0 2013-12-31 14:37 交通灯仿真\bin\
目录 0 2013-12-31 14:37 交通灯仿真\bin\com\
目录 0 2013-12-31 14:37 交通灯仿真\bin\com\traffic\
文件 2911 2013-12-31 14:30 交通灯仿真\bin\com\traffic\Car.class
文件 390 2013-12-31 12:42 交通灯仿真\bin\com\traffic\CarFactory.class
文件 1293 2013-12-31 13:47 交通灯仿真\bin\com\traffic\CarImage.class
文件 1072 2013-12-31 12:42 交通灯仿真\bin\com\traffic\DrawImage.class
文件 436 2013-12-31 12:42 交通灯仿真\bin\com\traffic\MainClass.class
文件 799 2013-12-31 14:31 交通灯仿真\bin\com\traffic\Mainfr
文件 3454 2013-12-31 14:32 交通灯仿真\bin\com\traffic\RoadPanel$CarRunThread.class
文件 1041 2013-12-31 14:32 交通灯仿真\bin\com\traffic\RoadPanel$CarThread.class
文件 1439 2013-12-31 14:32 交通灯仿真\bin\com\traffic\RoadPanel$LightThread.class
文件 7119 2013-12-31 14:32 交通灯仿真\bin\com\traffic\RoadPanel.class
文件 168265 2013-12-31 14:20 交通灯仿真\bluecar_down.png
文件 335169 2013-12-31 14:12 交通灯仿真\bluecar_left.png
文件 364915 2013-12-31 14:19 交通灯仿真\bluecar_right.png
文件 168641 2013-12-31 14:22 交通灯仿真\bluecar_up.png
文件 65469 2013-12-31 14:06 交通灯仿真\map.jpg
文件 410559 2013-12-31 14:26 交通灯仿真\redcar_down.png
文件 359008 2013-12-31 14:27 交通灯仿真\redcar_left.png
文件 364915 2013-12-31 14:26 交通灯仿真\redcar_right.png
文件 410559 2013-12-31 14:26 交通灯仿真\redcar_up.png
目录 0 2013-12-31 14:37 交通灯仿真\src\
目录 0 2013-12-31 14:37 交通灯仿真\src\com\
目录 0 2013-12-31 14:37 交通灯仿真\src\com\traffic\
............此处省略8个文件信息
- 上一篇:Java学生宿舍管理系统课程设计
- 下一篇:cos-2017.5.jar
相关资源
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
评论
共有 条评论