真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java寫的小項(xiàng)目代碼,編程小項(xiàng)目介紹

使用Java或者C#編寫一個(gè)小項(xiàng)目,求源碼或者思路,跪謝大佬

使用第三方庫poi就可以實(shí)現(xiàn)excel的讀取,讀入內(nèi)存后,編寫一個(gè)函數(shù),傳入十進(jìn)制然后轉(zhuǎn)為十六進(jìn)制即可。。

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供南樂網(wǎng)站建設(shè)、南樂做網(wǎng)站、南樂網(wǎng)站設(shè)計(jì)、南樂網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、南樂企業(yè)網(wǎng)站模板建站服務(wù),十載南樂做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

求JAVA小項(xiàng)目的完整代碼

給你個(gè)做好了的Java的源程序的記事本,自己看看就行了的,不怎么難的···

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{

private JFrame frame=new JFrame("新記事本");

private JTextArea jta=new JTextArea();

private String result="";

private boolean flag=true;

private File f;

private JButton jb=new JButton("開始");

private JTextField jtf=new JTextField(15);

private JTextField jt=new JTextField(15);

private JButton jbt=new JButton("替換為");

private JButton jba=new JButton("全部替換");

private Icon ic=new ImageIcon("D:\\java課堂筆記\\GUI\\11.gif");

private String value;

private int start=0;

private JFrame jf=new JFrame("查找");

private JFrame jfc=new JFrame("替換");

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("新建".equals(comm)){

if(!(frame.getTitle().equals("新記事本"))){

if(!flag){

write();

newNew();

}else{

JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");

int returnVal = jfc.showDialog(null,"保存為");

if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件后再執(zhí)行下面的語句,保證了程序的健壯性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

}else if(!(jta.getText().isEmpty())){

JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");

int returnVal = jfc.showDialog(null,"保存為");

if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件后再執(zhí)行下面的語句,保證了程序的健壯性

f=jfc.getSelectedFile();

flag=false;

write();

newNew();

}

}else{

newNew();

}

}else if("打開".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");

jfc.setDialogType(JFileChooser.OPEN_DIALOG);

int returnVal = jfc.showOpenDialog(null);

if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件后再執(zhí)行下面的語句,保證了程序的健壯性

f=jfc.getSelectedFile();

frame.setTitle(f.getName());

result=read();

flag=false;

value=result;

jta.setText(result);

}

}else if("保存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");

if(flag){

int returnVal = jfc.showDialog(null,"保存為");

if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件后再執(zhí)行下面的語句,保證了程序的健壯性

f=jfc.getSelectedFile();

flag=false;

write();

}

}else{

write();

}

}else if("另存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java課堂筆記");

int returnVal = jfc.showDialog(null,"另存");

if(returnVal == JFileChooser.APPROVE_OPTION) {//選擇文件后再執(zhí)行下面的語句,保證了程序的健壯性

f=jfc.getSelectedFile();

write();

}

}else if("退出".equals(comm)){

System.exit(0);

}else if("撤銷".equals(comm)){

jta.setText(value);

}else if("剪切".equals(comm)){

value=jta.getText();

jta.cut();

}else if("復(fù)制".equals(comm)){

jta.copy();

}else if("粘貼".equals(comm)){

value=jta.getText();

jta.paste();

}else if("刪除".equals(comm)){

value=jta.getText();

jta.replaceSelection(null);

}else if("全選".equals(comm)){

jta.selectAll();

}else if("查找".equals(comm)){

value=jta.getText();

jf.add(jtf,BorderLayout.CENTER);

jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);

jf.pack();

jf.setVisible(true);

jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("替換".equals(comm)){

value=jta.getText();

GridLayout gl=new GridLayout(3,3);

JLabel jl1=new JLabel("查找內(nèi)容:");

JLabel jl2=new JLabel("替換為:");

jfc.setLayout(gl);

jfc.add(jl1);

jfc.add(jtf);

jfc.add(jb);

jfc.add(jl2);

jfc.add(jt);

jfc.add(jbt);

JLabel jl3=new JLabel();

JLabel jl4=new JLabel();

jfc.add(jl3);

jfc.add(jl4);

jfc.add(jba);

jfc.setLocation(300,300);

jfc.pack();

jfc.setVisible(true);

jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("版本".equals(comm)){

JDialog jd=new JDialog(frame,"關(guān)于對話框");

jd.setSize(200,200);

JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");

jd.add(l,BorderLayout.CENTER);

jd.setLocation(100,200);

jd.setSize(300,300);

jd.setVisible(true);

// jd.pack();

jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}else if("開始".equals(comm)||"下一個(gè)".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jb.setText("下一個(gè)");

// value=value.substring(s+temp.length());//不能截取字串

}else {

JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);

jf.dispose();

}

}else if("替換為".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jta.replaceSelection(jt.getText());

}else {

JOptionPane.showMessageDialog(jf, "查找完畢!", "提示", 0, ic);

jf.dispose();

}

}else if("全部替換".equals(comm)){

String temp=jta.getText();

temp=temp.replaceAll(jtf.getText(), jt.getText());

jta.setText(temp);

}

}

public String read(){

String temp="";

try {

FileInputStream fis = new FileInputStream(f.getAbsolutePath());

byte[] b=new byte[1024];

while(true){

int num=fis.read(b);

if(num==-1)break;

temp=temp+new String(b,0,num);

}

fis.close();

} catch (Exception e1) {

e1.printStackTrace();

}

return temp;

}

public void write(){

try {

FileOutputStream fos=new FileOutputStream(f);

fos.write(jta.getText().getBytes());

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public void newNew(){

frame.dispose();

new MyNotepad();

flag=true;

}

public MyNotepad(){

JMenuBar jmb=new JMenuBar();

String[] menuLab={"文件","編輯","幫助"};

String[][] menuItemLab={{"新建","打開","保存","另存","退出"},

{"撤銷","剪切","復(fù)制","粘貼","刪除","全選","查找","替換"},

{"版本"}};

for(int i=0;imenuLab.length;i++){

JMenu menu=new JMenu(menuLab[i]);

jmb.add(menu);

for(int j=0;jmenuItemLab[i].length;j++){

JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);

menu.add(jmi);

jmi.addActionListener(this);

}

}

frame.setJMenuBar(jmb);

jta.setLineWrap(true);//自動換行

JScrollPane jsp=new JScrollPane(jta);//滾動窗口面板

frame.add(jsp);

jb.addActionListener(this);

jbt.addActionListener(this);

jba.addActionListener(this);

frame.setLocation(200,50);

frame.setSize(620,660);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new MyNotepad();

}

}

Java幫我寫下代碼~

項(xiàng)目結(jié)構(gòu)如下:

代碼如下

package?main;

public?class?Course?{

private?String?classNum;

private?String?credit;

private?String?startClassDate;

private?String?endClassDate;

private?String?teacher;

private?String?assessment;

public?String?getClassNum()?{

return?classNum;

}

public?void?setClassNum(String?classNum)?{

this.classNum?=?classNum;

}

public?String?getCredit()?{

return?credit;

}

public?void?setCredit(String?credit)?{

this.credit?=?credit;

}

public?String?getStartClassDate()?{

return?startClassDate;

}

public?void?setStartClassDate(String?startClassDate)?{

this.startClassDate?=?startClassDate;

}

public?String?getEndClassDate()?{

return?endClassDate;

}

public?void?setEndClassDate(String?endClassDate)?{

this.endClassDate?=?endClassDate;

}

public?String?getTeacher()?{

return?teacher;

}

public?void?setTeacher(String?teacher)?{

this.teacher?=?teacher;

}

public?String?getAssessment()?{

return?assessment;

}

public?void?setAssessment(String?assessment)?{

this.assessment?=?assessment;

}

@Override

public?String?toString()?{

return?"?課程號:"?+?classNum?+?",?學(xué)分:"?+?credit

+?",?上課時(shí)間:"?+?startClassDate?+?",?下課時(shí)間:"

+?endClassDate?+?",?教師:"?+?teacher?+?",??考核方式:"

+?assessment?+?"";

}

}

package?main;

import?java.io.BufferedInputStream;

import?java.io.BufferedReader;

import?java.io.File;

import?java.io.FileInputStream;

import?java.io.InputStreamReader;

import?java.math.BigDecimal;

import?java.util.ArrayList;

import?java.util.Arrays;

import?java.util.List;

import?java.util.Scanner;

public?class?Main?{

public?static?void?main(String[]?args)?throws?Exception?{

Scanner?sc?=?new?Scanner(System.in);???

System.out.println("創(chuàng)建學(xué)生請輸入姓名:");??

Student?stu1?=?new?Student();

stu1.setName(sc.nextLine());

Scanner?sc1?=?new?Scanner(System.in);???

System.out.println("創(chuàng)建學(xué)生請輸入學(xué)號:");

stu1.setNumber(sc1.nextLine());

System.out.println("請選擇課程,課程如下:");

ListCourse?list2?=?new?ArrayListCourse();

stu1.setCourses(list2);

ListCourse?list?=?readTxt();

for?(Course?course?:?list)?{

System.out.println(course.toString());

}

for?(int?i?=?1;?i??5;?i++)?{

System.out.println("請輸入第"+i+"個(gè)課程號:");

//輸入第一個(gè)課程號

list2?=?handleClass(list,?list2);

System.err.println("已選擇成功!");

list?=?notSelectClass(list,?list2);

System.out.println("請選擇課程,課程如下:");

if(i==4){

break;

}

for?(Course?course?:?list)?{

System.out.println(course.toString());

}

}

System.out.println("課程已選完!結(jié)果如下:");

System.err.println("學(xué)生:"+stu1.getName()+":");

for?(Course?course?:?list2)?{

System.err.println(course.toString());

}

}

/**

*?

*?查看未選擇可選課程

*?@param?list?全部可選課程

*?@param?list2?已選課程

*?@return

*/

private?static?ListCourse?notSelectClass(ListCourse?list,ListCourse?list2){

for?(int?i?=?0;?i??list.size();?i++)?{

for?(Course?course?:?list2)?{

//把已選課程剔除

if(course.getClassNum().equals(list.get(i).getClassNum())){

list.remove(i);

continue;

}

//把時(shí)間重合課程剔除??startdate1?=enddate2?and?enddate1=startdate2

if(daYuDengYu(course.getEndClassDate(),list.get(i).getStartClassDate())daYuDengYu(list.get(i).getEndClassDate(),?course.getStartClassDate())){

list.remove(i);

}

}

}

return?list;

}

public?static?boolean?daYuDengYu(String?first,?String?second){

BigDecimal?bd1?=?new?BigDecimal(first);

BigDecimal?bd2?=?new?BigDecimal(second);

return?bd1.compareTo(bd2)=0?true:false;

}

/**

*?處理選擇課程

*?@param?list

*?@param?list2

*?@return

*/

private?static?ListCourse?handleClass(ListCourse?list,ListCourse?list2){

while?(true)?{

Scanner?sssi?=?new?Scanner(System.in);

String?num?=?sssi.nextLine().trim();

for?(Course?course?:?list)?{

if(num.equals(course.getClassNum())){

list2.add(course);

return?list2;

}

}

System.out.println("課程號輸入錯(cuò)誤,請重新輸入:");

}

}

/**

*?讀取txt獲取課程??每個(gè)課程按;分割每個(gè)屬性按,分割

*?@return

*?@throws?Exception

*/

private?static?ListCourse?readTxt()?throws?Exception{

/*?讀入TXT文件?*/??

String?pathname?=?Main.class.getResource("/").toString();

pathname?=?pathname.substring(6,?pathname.length()-4)+"/src/classs/class.txt";?//獲取絕對路徑

File?filename?=?new?File(pathname);?//?要讀取以上路徑的txt文件??

ListCourse?list?=?new?ArrayListCourse();

BufferedInputStream?bis?=?new?BufferedInputStream(new?FileInputStream(filename));??

//讀取文件內(nèi)容??

byte[]?b?=?new?byte[bis.available()];??

bis.read(b);??

if(b!=null){

String?[]?strs=?new?String(b).split(";");

if?(strs==null)?{

return?null;

}

for?(String?string?:?strs)?{

String[]?str?=?string.split(",");

Course?course?=?new?Course();

course.setAssessment(str[5].trim());

course.setClassNum(str[0].trim());

course.setCredit(str[1].trim());

course.setEndClassDate(str[3].trim());

course.setStartClassDate(str[2].trim());

course.setTeacher(str[4].trim());

list.add(course);

}

}

bis.close();//關(guān)閉流(關(guān)閉bis就可以了)??

return?list;

}

}

package?main;

import?java.util.List;

public?class?Student?{

private?String?name;

private?String?number;

private?ListCourse?courses;

public?String?getName()?{

return?name;

}

public?void?setName(String?name)?{

this.name?=?name;

}

public?String?getNumber()?{

return?number;

}

public?void?setNumber(String?number)?{

this.number?=?number;

}

public?ListCourse?getCourses()?{

return?courses;

}

public?void?setCourses(ListCourse?courses)?{

this.courses?=?courses;

}

}

001,1,7,8,Joyce,assignment;

002,1,8,9,Joyce,assignment;

003,1,12,15,Joyce,assignment;

004,1,18,19,Joyce,assignment;

005,1,7,8,LI,assignment;

006,1,8,9,LI,assignment;

007,1,12,15,LI,assignment;

008,1,18,19,LI,assignment;

跪求java小項(xiàng)目,經(jīng)典小游戲代碼

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

public class GreedSnake implements KeyListener{

JFrame mainFrame;

Canvas paintCanvas;

JLabel labelScore;

SnakeModel snakeModel = null;

public static final int canvasWidth = 200;

public static final int canvasHeight = 300;

public static final int nodeWidth = 10;

public static final int nodeHeight = 10;

public GreedSnake() {

mainFrame = new JFrame("GreedSnake");

Container cp = mainFrame.getContentPane();

labelScore = new JLabel("Score:");

cp.add(labelScore, BorderLayout.NORTH);

paintCanvas = new Canvas();

paintCanvas.setSize(canvasWidth+1,canvasHeight+1);

paintCanvas.addKeyListener(this);

cp.add(paintCanvas, BorderLayout.CENTER);

JPanel panelButtom = new JPanel();

panelButtom.setLayout(new BorderLayout());

JLabel labelHelp;

labelHelp = new JLabel("PageUp, PageDown for speed;", JLabel.CENTER);

panelButtom.add(labelHelp, BorderLayout.NORTH);

labelHelp = new JLabel("ENTER or R or S for start;", JLabel.CENTER);

panelButtom.add(labelHelp, BorderLayout.CENTER);

labelHelp = new JLabel("SPACE or P for pause",JLabel.CENTER);

panelButtom.add(labelHelp, BorderLayout.SOUTH);

cp.add(panelButtom,BorderLayout.SOUTH);

mainFrame.addKeyListener(this);

mainFrame.pack();

mainFrame.setResizable(false);

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.setVisible(true);

begin();

}

public void keyPressed(KeyEvent e){

int keyCode = e.getKeyCode();

if (snakeModel.running)

switch(keyCode){

case KeyEvent.VK_UP:

snakeModel.changeDirection(SnakeModel.UP);

break;

case KeyEvent.VK_DOWN:

snakeModel.changeDirection(SnakeModel.DOWN);

break;

case KeyEvent.VK_LEFT:

snakeModel.changeDirection(SnakeModel.LEFT);

break;

case KeyEvent.VK_RIGHT:

snakeModel.changeDirection(SnakeModel.RIGHT);

break;

case KeyEvent.VK_ADD:

case KeyEvent.VK_PAGE_UP:

snakeModel.speedUp();

break;

case KeyEvent.VK_SUBTRACT:

case KeyEvent.VK_PAGE_DOWN:

snakeModel.speedDown();

break;

case KeyEvent.VK_SPACE:

case KeyEvent.VK_P:

snakeModel.changePauseState();

break;

default:

}

if (keyCode == KeyEvent.VK_R ||

keyCode == KeyEvent.VK_S ||

keyCode == KeyEvent.VK_ENTER){

snakeModel.running = false;

begin();

}

}

public void keyReleased(KeyEvent e){

}

public void keyTyped(KeyEvent e){

}

void repaint(){

Graphics g = paintCanvas.getGraphics();

//draw background

g.setColor(Color.WHITE);

g.fillRect(0,0,canvasWidth,canvasHeight);

// draw the snake

g.setColor(Color.BLACK);

LinkedList na = snakeModel.nodeArray;

Iterator it = na.iterator();

while(it.hasNext()){

Node n = (Node)it.next();

drawNode(g,n);

}

// draw the food

g.setColor(Color.RED);

Node n = snakeModel.food;

drawNode(g,n);

updateScore();

}

private void drawNode(Graphics g, Node n){

g.fillRect(n.x*nodeWidth,

n.y*nodeHeight,

nodeWidth-1,

nodeHeight-1);

}

public void updateScore(){

String s = "Score: " + snakeModel.score;

labelScore.setText(s);

}

void begin(){

if (snakeModel == null || !snakeModel.running){

snakeModel = new SnakeModel(this,

canvasWidth/nodeWidth,

canvasHeight/nodeHeight);

(new Thread(snakeModel)).start();

}

}

public static void main(String[] args){

GreedSnake gs = new GreedSnake();

}

}

///////////////////////////////////////////////////

// 文件2

///////////////////////////////////////////////////

import java.util.*;

import javax.swing.*;

class SnakeModel implements Runnable{

GreedSnake gs;

boolean[][] matrix;

LinkedList nodeArray = new LinkedList();

Node food;

int maxX;

int maxY;

int direction = 2;

boolean running = false;

int timeInterval = 200;

double speedChangeRate = 0.75;

boolean paused = false;

int score = 0;

int countMove = 0;

// UP and DOWN should be even

// RIGHT and LEFT should be odd

public static final int UP = 2;

public static final int DOWN = 4;

public static final int LEFT = 1;

public static final int RIGHT = 3;

public SnakeModel(GreedSnake gs, int maxX, int maxY){

this.gs = gs;

this.maxX = maxX;

this.maxY = maxY;

// initial matirx

matrix = new boolean[maxX][];

for(int i=0; imaxX; ++i){

matrix = new boolean[maxY];

Arrays.fill(matrix,false);

}

// initial the snake

int initArrayLength = maxX 20 ? 10 : maxX/2;

for(int i = 0; i initArrayLength; ++i){

int x = maxX/2+i;

int y = maxY/2;

nodeArray.addLast(new Node(x, y));

matrix[x][y] = true;

}

food = createFood();

matrix[food.x][food.y] = true;

}

public void changeDirection(int newDirection){

if (direction % 2 != newDirection % 2){

direction = newDirection;

}

}

public boolean moveOn(){

Node n = (Node)nodeArray.getFirst();

int x = n.x;

int y = n.y;

switch(direction){

case UP:

y--;

break;

case DOWN:

y++;

break;

case LEFT:

x--;

break;

case RIGHT:

x++;

break;

}

if ((0 = x x maxX) (0 = y y maxY)){

if (matrix[x][y]){

if(x == food.x y == food.y){

nodeArray.addFirst(food);

int scoreGet = (10000 - 200 * countMove) / timeInterval;

score += scoreGet 0? scoreGet : 10;

countMove = 0;

food = createFood();

matrix[food.x][food.y] = true;

return true;

}

else

return false;

}

else{

nodeArray.addFirst(new Node(x,y));

matrix[x][y] = true;

n = (Node)nodeArray.removeLast();

matrix[n.x][n.y] = false;

countMove++;

return true;

}

}


本文題目:java寫的小項(xiàng)目代碼,編程小項(xiàng)目介紹
本文路徑:http://weahome.cn/article/hdpecg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部