网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

大学guan网java代码 java代码交流网站

学生考试管理系统,JAva源代码

//主类EnglishTest——

我们提供的服务有:成都网站设计、做网站、微信公众号开发、网站优化、网站认证、白银区ssl等。为数千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的白银区网站制作公司

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class EnglishTest extends JFrame

{

TestArea testPanel=null;

Container con=null;

public EnglishTest()

{

super("模拟考试");

testPanel=new TestArea();

con=getContentPane();

con.add(testPanel,BorderLayout.CENTER);

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{ System.exit(0);

}

});

setVisible(true);

setBounds(60,40,660,460);

con.validate();

validate();

}

public static void main(String args[])

{

new EnglishTest();

}

}

//读取试题 ReadTestquestion

import java.io.*;

import java.util.*;

public class ReadTestquestion

{ String filename="",

correctAnswer="",

testContent="" ,

selection="" ;

int score=0;

long time=0;

boolean 完成考试=false;

File f=null;

FileReader in=null;

BufferedReader 读取=null;

public void setFilename(String name)

{ filename=name;

score=0;

selection="";

try {

if(in!=null读取!=null)

{

in.close();

读取.close();

}

f=new File(filename);

in=new FileReader(f);

读取=new BufferedReader(in);

correctAnswer=(读取.readLine()).trim();

String temp=(读取.readLine()).trim() ;

StringTokenizer token=new StringTokenizer(temp,":");

int hour=Integer.parseInt(token.nextToken()) ;

int minute=Integer.parseInt(token.nextToken());

int second=Integer.parseInt(token.nextToken());

time=1000*(second+minute*60+hour*60*60);

}

catch(Exception e)

{

testContent="没有选择试题";

}

}

public String getFilename()

{

return filename;

}

public long getTime()

{

return time;

}

public void set完成考试(boolean b)

{

完成考试=b;

}

public boolean get完成考试()

{

return 完成考试;

}

public String getTestContent()

{ try {

String s=null;

StringBuffer temp=new StringBuffer();

if(读取!=null)

{

while((s=读取.readLine())!=null)

{

if(s.startsWith("**"))

break;

temp.append("\n"+s);

if(s.startsWith("endend"))

{

in.close();

读取.close();

完成考试=true;

}

}

testContent=new String(temp);

}

else

{

testContent=new String("没有选择试题");

}

}

catch(Exception e)

{

testContent="试题内容为空,考试结束!!";

}

return testContent;

}

public void setSelection(String s)

{

selection=selection+s;

}

public int getScore()

{ score=0;

int length1=selection.length();

int length2=correctAnswer.length();

int min=Math.min(length1,length2);

for(int i=0;imin;i++)

{ try{

if(selection.charAt(i)==correctAnswer.charAt(i))

score++;

}

catch(StringIndexOutOfBoundsException e)

{

i=0;

}

}

return score;

}20:10 03-8-31

public String getMessages()

{

int length1=selection.length();

int length2=correctAnswer.length();

int length=Math.min(length1,length2);

String message="正确答案:"+correctAnswer.substring(0,length)+"\n"+

"你的回答:"+selection+"\n";

return message;

}

}

//考试区域TestArea

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.io.*;

class FileName implements FilenameFilter

{

String str=null;

FileName (String s)

{

str="."+s;

}

public boolean accept(File dir,String name)

{

return name.endsWith(str);

}

}

public class TestArea extends JPanel implements ActionListener,ItemListener,Runnable

{

Choice list=null;

JTextArea 试题显示区=null,消息区=null;

JCheckBox box[];

JButton 提交该题答案,读取下一题,查看分数;

ReadTestquestion 读取试题=null;

JLabel welcomeLabel=null;

Thread countTime=null;

long time=0;

JTextField timeShow=null;

boolean 是否关闭计时器=false,

是否暂停计时=false;

JButton 暂停或继续计时=null;

public TestArea()

{

list= new Choice();

String 当前目录=System.getProperty("user.dir");

File dir=new File(当前目录);

FileName fileTxt=new FileName("txt");

String fileName[]=dir.list(fileTxt);

for(int i=0;ifileName.length;i++)

{

list.add(fileName[i]);

}

试题显示区=new JTextArea(15,12);

试题显示区.setLineWrap(true);

试题显示区.setWrapStyleWord(true);

试题显示区.setFont(new Font("TimesRoman",Font.PLAIN,14));

试题显示区.setForeground(Color.blue);

消息区=new JTextArea(8,8);

消息区.setForeground(Color.blue);

消息区.setLineWrap(true);

消息区.setWrapStyleWord(true);

countTime=new Thread(this);

String s[]={"A","B","C","D"};

box=new JCheckBox[4];

for(int i=0;i4;i++)

{

box[i]=new JCheckBox(s[i]);

}

暂停或继续计时=new JButton("暂停计时");

暂停或继续计时.addActionListener(this);

提交该题答案=new JButton("提交该题答案");

读取下一题=new JButton("读取第一题");

读取下一题.setForeground(Color.blue);

提交该题答案.setForeground(Color.blue);

查看分数=new JButton("查看分数");

查看分数.setForeground(Color.blue);

提交该题答案.setEnabled(false);

提交该题答案.addActionListener(this);

读取下一题.addActionListener(this);

查看分数.addActionListener(this);

list.addItemListener(this);

读取试题=new ReadTestquestion();

JPanel pAddbox=new JPanel();

for(int i=0;i4;i++)

{

pAddbox.add(box[i]);

}

Box boxH1=Box.createVerticalBox(),

boxH2=Box.createVerticalBox(),

baseBox=Box.createHorizontalBox();

boxH1.add(new JLabel("选择试题文件"));

boxH1.add(list);

boxH1.add(new JScrollPane(消息区));

boxH1.add(查看分数);

timeShow=new JTextField(20);

timeShow.setHorizontalAlignment(SwingConstants.RIGHT);

timeShow.setEditable(false);

JPanel p1=new JPanel();

p1.add(new JLabel("剩余时间:"));

p1.add(timeShow);

p1.add(暂停或继续计时);

boxH1.add(p1);

boxH2.add(new JLabel("试题内容:"));

boxH2.add(new JScrollPane(试题显示区));

JPanel p2=new JPanel();

p2.add(pAddbox);

p2.add(提交该题答案);

p2.add(读取下一题);

boxH2.add(p2);

baseBox.add(boxH1);

baseBox.add(boxH2);

setLayout(new BorderLayout());

add(baseBox,BorderLayout.CENTER);

welcomeLabel=new JLabel("欢迎考试,提高英语水平",JLabel.CENTER);

welcomeLabel.setFont(new Font("隶书",Font.PLAIN,24));

welcomeLabel.setForeground(Color.blue);

add(welcomeLabel,BorderLayout.NORTH);

}

public void itemStateChanged(ItemEvent e)

{

timeShow.setText(null);

是否关闭计时器=false;

是否暂停计时=false;

暂停或继续计时.setText("暂停计时");

String name=(String)list.getSelectedItem();

读取试题.setFilename(name);

读取试题.set完成考试(false);

time=读取试题.getTime();

if(countTime.isAlive())

{

是否关闭计时器=true;

countTime.interrupt();

}

countTime=new Thread(this);

消息区.setText(null);

试题显示区.setText(null);

读取下一题.setText("读取第一题");

提交该题答案.setEnabled(false);

读取下一题.setEnabled(true);

welcomeLabel.setText("欢迎考试,你选择的试题:"+读取试题.getFilename());

}

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==读取下一题)

{

读取下一题.setText("读取下一题");

提交该题答案.setEnabled(true);

String contentTest=读取试题.getTestContent();

试题显示区.setText(contentTest);

消息区.setText(null);

读取下一题.setEnabled(false);

try {

countTime.start();

}

catch(Exception event)

{

}

}

if(e.getSource()==提交该题答案)

{

读取下一题.setEnabled(true);

提交该题答案.setEnabled(false);

String answer="?";

for(int i=0;i4;i++)

{

if(box[i].isSelected())

{

answer=box[i].getText();

box[i].setSelected(false);

break;

}

}

读取试题.setSelection(answer);

}

if(e.getSource()==查看分数)

{

int score=读取试题.getScore();

String messages=读取试题.getMessages();

消息区.setText("分数:"+score+"\n"+messages);

}

if(e.getSource()==暂停或继续计时)

{

if(是否暂停计时==false)

{

暂停或继续计时.setText("继续计时");

是否暂停计时=true;

}

else if(是否暂停计时==true)

{

暂停或继续计时.setText("暂停计时");

是否暂停计时=false;

countTime.interrupt();

}

}

}

public synchronized void run()

{

while(true)

{

if(time=0)

{

是否关闭计时器=true;

countTime.interrupt();

提交该题答案.setEnabled(false);

读取下一题.setEnabled(false);

timeShow.setText("用时尽,考试结束");

}

else if(读取试题.get完成考试())

{

是否关闭计时器=true;

timeShow.setText("考试效果:分数*剩余时间(秒)="+1.0*读取试题.getScore()*(time/1000));

countTime.interrupt();

提交该题答案.setEnabled(false);

读取下一题.setEnabled(false);

}

else if(time=1)

{

time=time-1000;

long leftTime=time/1000;

long leftHour=leftTime/3600;

long leftMinute=(leftTime-leftHour*3600)/60;

long leftSecond=leftTime%60;

timeShow.setText(""+leftHour+"小时"+leftMinute+"分"+leftSecond+"秒");

}

try

{

Thread.sleep(1000);

}

catch(InterruptedException ee)

{

if(是否关闭计时器==true)

return ;

}

while(是否暂停计时==true)

{

try

{

wait();

}

catch(InterruptedException ee)

{

if(是否暂停计时==false)

{

notifyAll();

}

}

}

}

}

}

求JAVA实验代码

public interface Student {

// 该方法用于表示不同阶段的学生在学习数学课程时的不同内容

public abstract void studyMath();

// 该方法用于表示不同阶段的学生的英语水平

public abstract void studyEnglish();

}

public class PrimarySchoolStudent implements Student {

@Override

public void studyMath() {

System.out.println("小学生在学习数学课程时,主要学习加减法,数学表达式等基础知识。");

}

@Override

public void studyEnglish() {

System.out.println("小学生在学习英语时,主要学习词汇,基本句型,基本语法等基础知识。");

}

}

public class MiddleSchoolStudent implements Student {

@Override

public void studyMath() {

System.out.println("中学生在学习数学课程时,主要学习初等函数,代数方程等基础知识。");

}

@Override

public void studyEnglish() {

System.out.println("中学生在学习英语时,主要学习阅读理解,听力理解,口语交流等能力。");

}

}

public class CollegeStudent implements Student {

@Override

public void studyMath() {

System.out.println("大学生在学习数学课程时,主要学习高等数学,概率论,数值计算等专业知识。");

}

@Override

public void studyEnglish() {

System.out.println("大学生在学习英语时,主要学习专业英语,商务英语,英文写作等能力。");

}

}

public class Main {

public static void main(String[] args) {

java:哪里能看到JDK的源代码?

你安装JDK的目录下,有个src.zip文件,这个就是JDK源代码的java文件。

你可以解压来查看,但,最好是关联到IDE如 eclipse 中(不需解压),然后 CTRL + 点击就可以查看到源代码了。

如下图:

java代码怎样运行出来?

步骤:

1、在cmd中切换到编写的代码所保存的目录下;

2、在cmd中输入javac然后点空格,再点击文件名和包括后缀名确定后,在存放编写代码的文件下会生成一个class的字节码文件;

3、在cmd中输入java然后点空格,输入第二步中生成的字节码的文件名,不需要后缀名,点击确定即可运行代码。

代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。计算机代码称为源代码,是相对目标代码和可执行代码而言的。 源代码就是用汇编语言和高级语言写出来的地代码,目标代码是指源代码经过编译程序产生的能被cpu直接识别二进制代码。


当前名称:大学guan网java代码 java代码交流网站
网站路径:http://bjjierui.cn/article/doicedo.html

其他资讯