大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
当前来说,大部分的OA系统都是通过java的形式来实现的,可以将OA系统源码导入到eclipse中查看即可。
创新互联建站是一家专业提供石泉企业网站建设,专注与网站设计制作、成都做网站、H5建站、小程序制作等业务。10年已为石泉众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
步骤一:打开eclipse,选择菜单栏的file下拉选的import进入项目引入设置界面。
步骤二:选择要导入的项目路径后,勾选上projects中的项目名称。
步骤三:点击页面右下角的“Finish”即可完成项目引入。
第四步:在引入的项目上右击,选择run on server运行即可。
我用了半个小时 帮你写了一个简单的验证用户名和密码登陆问题 别辜负我的好意 下面是代码!(建好包和类 代码粘过去就能用)
实体类 包entity
-------------------------------------------------------------
package entity;
/**
* 用户实体类
* @author new
*
*/
public class Users {
private String name;//用户名
private String pass;//用户密码
/**
* 空的构造函数 用户实力化 此类对象
*/
public Users(){
}
/**
* 构造函数 接收用户名和密码
* @param name
* @param pass
*/
public Users(String name, String pass) {
this.name = name;
this.pass = pass;
}
/**
* 下面set和get方法就不用解释了吧
* @return
*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
}
数据库类 包dao(我是模拟一下数据库 没有用到数据库)
--------------------------------------------------------------
package dao;
import java.util.*;
import entity.Users;//导入实体类
/**
* 模拟数据库 用户DAO
* @author new
*
*/
public class UsersDAO {
private static Users users=new Users();
static
{
users.setName("tom");
users.setPass("jerry");
}
/**
* 根据姓名查找这个用户 (模拟一下数据库)
* @param name
* @return
*/
public Users findUserByName(String name)
{
if(name.equals(this.users.getName()))
{
return this.users;
}
return null;
}
}
业务类 包service (验证用户名和密码)
------------------------------------------------------------
package service;
import dao.UsersDAO;
import entity.Users;
/**
* 验证密码 业务类
* @author new
*
*/
public class validatePass {
//实力化DAO对象
private UsersDAO us=new UsersDAO();
/**
* 验证输入的密码是否正确
* @param name
* @param pass
* @return
*/
public Users validate(String name,String pass)
{
Users user=null;
user=us.findUserByName(name);
//如果不为空 说明查到了
if(user!=null)
{
//用查询出来对象的密码和传过来的密码比较
if(user.getPass().equals(pass))
{
return user;
}
}
return null;
}
}
最后是测试test类 包test
----------------------------------------------------------
package test;
import entity.Users;
import service.validatePass;
/**
* 测试类
* @author new
*
*/
public class test {
/**
* main方法 用于测试
* @param args
*/
public static void main(String[] args)
{
//实例化业务类对象
validatePass v=new validatePass();
//用户名和密码
String name="tom";
String pass="jerry";
//开始验证
Users user=v.validate(name, pass);
if(user==null)
{
System.out.println("你输入的用户名或密码错误!");
}else
{
System.out.println("你已经通过验证,成功登陆!");
}
}
}
兄弟可以联系 hi留言也行
我这里保留了,从学习java第一天起到现在 学习练习代码,
基础部分注释很详细。
//每一位相加求和
public class Demo
{
public static void main(String[] args)
{
int i = 45678;
int sum = 0;
int c = 0;
for(int j = 4; j = 0; j--)
{
int b = (int) Math.pow(10, j);
c = i / b;
System.out.println(c);
sum += c;
System.out.println("sum=" + sum);
i %= b;
}
System.out.println(sum);
}
}
public class ZY1030
{
public static void main(String[] asgs)
{
zy1();
zy2();
zy3();
zy4();
zy5();
zy6();
zy7();
yanghuisanjiao();
}
public static void yanghuisanjiao()
{
int[][] pas = new int[6][];
for(int i = 0; i pas.length; i++)
{
pas[i] = new int[i + 1];
pas[i][0] = 1;
pas[i][i] = 1;
for(int j = 0; j pas[i].length - 1; j++)
{
if(j = 1 i 1)
pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j];
}
}
for(int i = 0; i pas.length; i++)
{
for(int j = 0; j pas[i].length; j++)
{
System.out.print(pas[i][j]);
System.out.println();
}
}
System.out.println();
}
private static void zy1()
{
System.out.println("��ҵ1");
/*
*
**
***
****
*****
******
*******
*/
for(int r = 0; r 7; r++)
{
for(int j = 0; j r + 1; j++)
{
System.out.print("*");
}
System.out.println();
}
}
private static void zy2()
{
System.out.println("\n��ҵ2");
/*
*
***
*****
*******
*********
*/
for(int r = 0; r = 5; r++)
{
for(int j = 0; j 11 - r; j++)
{
System.out.print(" ");
}
for(int j = 0; j r * 2 + 1; j++)
{
System.out.print("*");
}
System.out.println();
}
}
private static void zy3()
{
System.out.println("\n��ҵ3");
/*
*
* *
* * *
* * * *
* * * * *
*/
for(int r = 0; r = 5; r++)
{
for(int j = 0; j 10 - r; j++)
{
System.out.print(" ");
}
for(int j = 0; j r; j++)
{
System.out.print("* ");
}
System.out.println();
}
}
private static void zy4()
{
System.out.println("\n��ҵ4");
/*
***********
***********
***********
***********
***********
*/
for(int r = 0; r = 5; r++)
{
for(int j = 0; j 7 - r; j++)
{
System.out.print(" ");
}
for(int j = 0; j 10; j++)
{
System.out.print("*");
}
System.out.println();
}
}
private static void zy5()
{
System.out.println("\n��ҵ5");
/*
1X1=1
1X2=2 2X2=4
1X3=3 2X3=6 3X3=9
....
*/
for(int r = 1; r = 9; r++)
{
for(int j = 1; j = r; j++)
{
int iValue = j * r; //����ֵ
String str = j + "X" + r + "=" + iValue + " ";
System.out.print(str);
//System.out.print(" J:" + j);
}
System.out.println();
//System.out.println("R:" + r);
}
}
private static void zy6()
{
System.out.println("\n��ҵ6");
/*
������(����) ֻ�ܱ�1�ͱ����������������
3 5 7 11 13 17 19 23 ....
int n = 4;
boolean t = true; // assume is SU_SHU
for(int i=2; in; i++)
{
if(n%i==0)
{
t = false;
break;
}
}
System.out.println(t);
*/
for(int i = 2; i = 100; i++)
{
// if(i % 2 ==0 || i % 3 == 0 )
// {
// continue;
// }
// System.out.print(i + " ");
boolean bTrue = true;
for(int j = 2; j i; j++)
{
if(i % j == 0)
{
bTrue = false;
break;
}
}
if(bTrue)
{
System.out.println(i);
}
}
System.out.println();
}
private static void zy7()
{
System.out.println("\n��ҵ7");
/*
int n = 23623;
int x = n % 100000 / 10000;
System.out.println(x);
x = n % 10000 / 1000;
System.out.println(x);
x = n % 1000 / 100;
System.out.println(x);
*/
}
}
你说的java源代码是指编译成的class文件前的java文件。
当我们运行.java文件时,它会被系统编译成.class文件,例如Test.java编译之后就是Test.class,
源文件就是指Test.java文件,
一般部署项目时,有.class文件就可以发布运行了,但是如果想修改这个系统,.class是不能修改的,要有.java文件才能修改
也可以上网去下反编译软件,就是能把.class文件大部分还原成.java文件的工具,但不是100%还原,而且如果不是正版的,小心有毒啊,什么的。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ConstructFrame extends JFrame
{
private static final long serialVersionUID = 1L;
String value1="",result,value2="";
int flag=0,fix=0,sum=1;
Boolean happy;
JTextField text=new JTextField(30);
int flagsum=0;
Container c=getContentPane();
JButton buttonx;
ConstructFrame()
{ super("计算器");
c.setLayout(null);
c.setBackground(Color.blue);
this.setSize(400, 400);
c.add(text);
text.setHorizontalAlignment(JTextField.RIGHT);
final JButton buttonx=new JButton("BackSpace");
c.add(buttonx);
buttonx.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
int count=0;
String temp;
if(flag==0)
{
count=value1.length();
if(count!=1)
temp=value1.substring(0, count-1);
else
temp="0";
value1=temp;
}
else
{
count=value2.length();
if(count!=1)
temp=value2.substring(0, count-1);
else
temp="0";
value2=temp;
}
text.setText(temp);
}
});
final JButton buttony=new JButton("CE");
c.add(buttony);
buttony.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
value1="";
value2="";
flag=0;
text.setText("0");
}
});
final JButton button1=new JButton("1");
c.add(button1);
button1.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+1;
temp=value1;
}
else
{
value2=value2+1;
temp=value2;
}
text.setText(temp);
}
});
final JButton button2=new JButton(" 2 ");
c.add(button2);
button2.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+2;
temp=value1;
}
else
{
value2=value2+2;
temp=value2;
}
text.setText(temp);
}
});
final JButton button3=new JButton("3");
c.add(button3);
button3.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+3;
temp=value1;
}
else
{
value2=value2+3;
temp=value2;
}
text.setText(temp);
}
});
final JButton button4=new JButton("4");
c.add(button4);
button4.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+4;
temp=value1;
}
else
{
value2=value2+4;
temp=value2;
}
text.setText(temp);
}
});
final JButton button5=new JButton("5");
c.add(button5);
button5.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+5;
temp=value1;
}
else
{
value2=value2+5;
temp=value2;
}
text.setText(temp);
}
});
final JButton button6=new JButton("6");
c.add(button6);
button6.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+6;
temp=value1;
}
else
{
value2=value2+6;
temp=value2;
}
text.setText(temp);
}
});
final JButton button7=new JButton("7");
c.add(button7);
button7.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+7;
temp=value1;
}
else
{
value2=value2+7;
temp=value2;
}
text.setText(temp);
}
});
final JButton button8=new JButton("8");
c.add(button8);
button8.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+8;
temp=value1;
}
else
{
value2=value2+8;
temp=value2;
}
text.setText(temp);
}
});
final JButton button9=new JButton("9");
c.add(button9);
button9.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+9;
temp=value1;
}
else
{
value2=value2+9;
temp=value2;
}
text.setText(temp);
}
});
final JButton button0=new JButton("0");
c.add(button0);
button0.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String temp;
if(flag==0)
{
value1=value1+0;
temp=value1;
}
else
{
value2=value2+0;
temp=value2;
}
text.setText(temp);
}
});
final JButton buttonadd=new JButton(" + ");
c.add(buttonadd);
buttonadd.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=1;
flagsum=0;
}
});
final JButton buttonsubtract=new JButton(" - ");
c.add(buttonsubtract);
buttonsubtract.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=2;
flagsum=0;
}
});
final JButton buttoncheng=new JButton(" * ");
c.add(buttoncheng);
buttoncheng.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
fix=3;
flagsum=0;
}
});
final JButton buttonchu=new JButton(" / ");
c.add(buttonchu);
buttonchu.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
flag=1;
flagsum=0;
fix=4;
}
});
final JButton buttonequal=new JButton(" = ");
c.add(buttonequal);
buttonequal.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
double temp1,temp2;
double temp=0;
flagsum=0;
temp1=Double.parseDouble(value1);
temp2=Double.parseDouble(value2);
flag=0;
switch(fix)
{
case 1: temp=temp1+temp2;break;
case 2: temp=temp1-temp2;break;
case 3: temp=temp1*temp2;break;
case 4: temp=temp1/temp2;break;
}
result=Double.valueOf(temp).toString();
value1=result;
value2="";
flag=1;
text.setText(result);
}
});
final JButton buttonpoint=new JButton(".");
c.add(buttonpoint);
buttonpoint.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{ if(flagsum==0)
{
String temp;
if(flag==0 )
{
value1=value1+".";
temp=value1;
}
else
{
value2=value2+".";
temp=value2;
}
flagsum=1;
text.setText(temp);
}
}
});
JButton buttonz=new JButton("Start");
c.add(buttonz);
buttonz.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{ if(sum%2==1)
{
happy=true;
text.setText("0.");
flag=0;
}
else
{
happy=false;
value1="";
value2="";
text.setText("");
}
text.setEnabled(happy);
button1.setEnabled(happy);
button2.setEnabled(happy);
button3.setEnabled(happy);
button4.setEnabled(happy);
button5.setEnabled(happy);
button6.setEnabled(happy);
button7.setEnabled(happy);
button8.setEnabled(happy);
button9.setEnabled(happy);
button0.setEnabled(happy);
buttonx.setEnabled(happy);
buttony.setEnabled(happy);
buttonadd.setEnabled(happy);
buttonsubtract.setEnabled(happy);
buttonpoint.setEnabled(happy);
buttonequal.setEnabled(happy);
buttoncheng.setEnabled(happy);
buttonchu.setEnabled(happy);
sum++;
}
});
button1.setEnabled(false);
button2.setEnabled(false);
button3.setEnabled(false);
button4.setEnabled(false);
button5.setEnabled(false);
button6.setEnabled(false);
button7.setEnabled(false);
button8.setEnabled(false);
button9.setEnabled(false);
button0.setEnabled(false);
buttonx.setEnabled(false);
buttony.setEnabled(false);
buttonadd.setEnabled(false);
buttonsubtract.setEnabled(false);
buttonpoint.setEnabled(false);
buttonequal.setEnabled(false);
buttoncheng.setEnabled(false);
buttonchu.setEnabled(false);
text.setEnabled(false);
text.setBounds(20, 20, 200, 40);
buttonx.setBounds(20, 60,100, 40);
buttony.setBounds(140, 60,100, 40);
buttonz.setBounds(260, 60,80, 40);
button1.setBounds(20, 120,60, 40);
button2.setBounds(100, 120,60, 40);
button3.setBounds(180, 120,60, 40);
buttonadd.setBounds(260, 120,60, 40);
button4.setBounds(20, 180,60, 40);
button5.setBounds(100, 180,60, 40);
button6.setBounds(180, 180,60, 40);
buttonsubtract.setBounds(260, 180,60, 40);
button7.setBounds(20, 240,60, 40);
button8.setBounds(100, 240,60, 40);
button9.setBounds(180, 240,60, 40);
buttoncheng.setBounds(260,240,60,40);
button0.setBounds(20, 300,60, 40);
buttonpoint.setBounds(100, 300, 60, 40);
buttonequal.setBounds(180,300,60, 40);
buttonchu.setBounds(260, 300,60, 40);
setVisible(true);
}
class MYMouseEvent extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
value1=e.toString();
text.setText(value1);
}
}
}
class Calutator
{
public static void main(String[] args)
{
new ConstructFrame();
}
}
你自己慢慢的看吧!