符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
public interface Student {
我们提供的服务有:做网站、成都网站制作、微信公众号开发、网站优化、网站认证、尼金平ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的尼金平网站制作公司
// 该方法用于表示不同阶段的学生在学习数学课程时的不同内容
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) {
Shape.java接口代码
public interface Shape {
public static final double PI = 3.14d;
public double area();
}
Circle.java圆类代码
public class Circle implements Shape {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
@Override
public double area() {
return PI * this.radius * this.radius;
}
public double perimeter() {
return 2 * PI * this.radius;
}
}
Cylinder.java圆柱体类代码
public class Cylinder extends Circle {
private double height;
public Cylinder(double radius, double height) {
super(radius);
this.height = height;
}
public double area() {
return 2 * super.area() + super.perimeter() * this.height;
}
public double volume() {
return super.area() * this.height;
}
}
X5_3_6.java主类代码
public class X5_3_6 {
public static void main(String[] args) {
Circle cir1 = new Circle(5);
System.out.println("圆的面积为:" + cir1.area());
System.out.println("圆的周长为:" + cir1.perimeter());
Cylinder cy1 = new Cylinder(10, 15);
System.out.println("圆柱体的表面积为:" + cy1.area());
System.out.println("圆柱体的体积为:" + cy1.volume());
}
}
上面是我写的代码,下图是执行结果,麻烦看一下,是否可以。
哎,我还是自己代码黏贴给你吧!免得总通不过!装不下这么多字,详情自己找我。 连接数据库类(添加修改会员信息) package com.to.java; import java.util.Scanner; import java.sql.*; public class Vds { Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); public void x(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); System.out.println("----------查询结果---------"); System.out.println(); System.out.println("会员号--密码"); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } con.close(); stmt.close(); }catch(Exception e){ System.out.println(e);} System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; }} public void j(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入会员号:"); String f=input.next(); System.out.println("请输入密码:"); String q=input.next(); String sqlst="insert into gg values('"+f+"','"+q+"')"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } public void xg(){ try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select id,mm from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); System.out.println(id+" "+mm); } Scanner input=new Scanner(System.in); System.out.println("请输入会员信息:"); System.out.println("请输入要修改的会员号:"); String f=input.next(); System.out.println("请输入修改的密码:"); String q=input.next(); String sqlst="update gg set mm='"+q+"' where id='"+f+"'"; Statement tatement=con.createStatement(); int result=tatement.executeUpdate(sqlst); System.out.println("操作成功!"); con.close(); stmt.close(); }catch(Exception e){ System.out.println(e); } System.out.println("是否返回上级菜单"); System.out.println("1.是"); System.out.println("2.否"); int m=Input.nextInt(); switch(m){ case 1: zhuck1.ZhucK1(); break; case 2: { System.out.println("欢迎下次再次使用");System.exit(-1);}; break; } } } package com.to.java; import java.util.Scanner; public class KeHu { Vds sj=new Vds(); public void kehu1(){ Scanner Input=new Scanner(System.in); ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("******************************************************"+"\n\n"); System.out.println("1.显示所有客户信息"); System.out.println("2.添加客户信息"); System.out.println("3.修改客户信息"); System.out.println("4.查询客户信息"); System.out.println("5.返回上级菜单"); System.out.println("******************************************************"+"\n\n"); System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: sj.x(); break; case 2: sj.j(); break; case 3: sj.xg(); break; case 4: sj.x();break; case 5: zhuck1.ZhucK1();break; } } } package com.to.java; public class GouWuXiTong { public static void main(String[] args){ ZhuCK zhuck=new ZhuCK(); zhuck.ZhucK(); } } package com.to.java; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Scanner; public class ZhuCK { Scanner Input=new Scanner(System.in); public void ZhucK(){ ZhuCK1 zhuck1=new ZhuCK1(); System.out.println("\t\t"+"欢迎使用我心我素购物系统"); System.out.println("******************************************************"+"\n\n"); System.out.println("\t\t"+"1.登陆系统"); System.out.println(); System.out.println("\t\t"+"2.退出"+"\n\n"); System.out.println("******************************************************"); int d=1; while(d!=2){ System.out.println("请输入会员号:"); String p=Input.next(); System.out.println("请输入密码:"); String f=Input.next(); try{ Connection con=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String ur1="jdbc:odbc:gg"; con=DriverManager.getConnection(ur1); stmt=con.createStatement(); String sqlstmt="select * from gg"; rs=stmt.executeQuery(sqlstmt); while(rs.next()){ String id=rs.getString("id"); String mm=rs.getString("mm"); if(id.equals(p)mm.equals(f)){ { System.out.println("请输入数字:"); int a=Input.nextInt(); switch(a){ case 1: zhuck1.ZhucK1(); break; case 2: break; }d=2; } } } }catch(Exception e){ System.out.println(e);} {System.out.println("输入错误请再次输入:");d=1;} } }} }
2,3已经实现,其他的自己试着做一下不难
package com.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
class NoteBook{
//创建文件
public File creatFile(String path,String name){
File tempPath=new File(path);
File tempFile=new File(path+File.separator+name+".txt");
if(!tempPath.exists()){
tempPath.mkdirs();
try {
tempFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
try {
tempFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return tempFile;
}
//写入文件
public void writeFile(File file,String content){
try {
FileOutputStream fos=new FileOutputStream(file);
fos.write(content.getBytes());
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//读取文件
public String readFile(File file){
String str="";
try {
FileInputStream fis=new FileInputStream(file);
int datas;
while((datas=fis.read())!=-1){
str+=String.valueOf((char)datas);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
//复制文件
public void copyFile(File f1,File f2){
if(!f1.exists()){
System.out.println("目录"+f1.getName()+"不存在");
}else{
File[] files=f1.listFiles();
for(File f:files){
if(f.isDirectory()){
File temp=new File(f2,f.getName());
temp.mkdirs();
copyFile(f, temp);
}else{
File temp=new File(f2,f.getName());
try {
temp.createNewFile();
FileOutputStream fos=new FileOutputStream(temp);
FileInputStream fis=new FileInputStream(f);
int datas;
while((datas=fis.read())!=-1){
fos.write(datas);
}
fos.close();
fis.close();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
//剪贴文件
public void cutFile(File f1,File f2){
int i=0;
if(!f1.exists()){
System.out.println("目录"+f1.getName()+"不存在");
}else{
i++;
File[] files=f1.listFiles();
for(File f:files){
if(f.isDirectory()){
File temp=new File(f2,f.getName());
temp.mkdirs();
cutFile(f, temp);
}else{
File temp=new File(f2,f.getName());
try {
temp.createNewFile();
FileOutputStream fos=new FileOutputStream(temp);
FileInputStream fis=new FileInputStream(f);
int datas;
while((datas=fis.read())!=-1){
fos.write(datas);
}
fis.close();
fos.close();
f.delete();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
f1.delete();
}
}
算是最简单的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陆菜单 ");
System.out.println("1登陆系统");
System.out.println("2退出");
}
static void choice1() {
System.out.println("购物管理系统客户信息");
System.out.println("1显示所有客户信息");
System.out.println("2添加客户信息");
System.out.println("3修改客户信息");
System.out.println("4查询客户信息");
}
static void choice2() {
System.out.println("购物管理系统真情回馈");
System.out.println("1幸运大放送");
System.out.println("2幸运抽奖");
System.out.println("3生日问候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("请输入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜单");
System.out.println("1客户信息管理");
System.out.println("2购物结算");
System.out.println("3真情回馈");
System.out.println("4注销");
break;
}
System.out.println("选择输入数字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("购物结算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
这篇文章主要介绍了java通过JFrame做一个登录系统的界面完整代码示例,具有一定借鉴价值,需要的朋友可以参考下。
在java的JFrame内通过创建匿名对象的方式做登录界面
package com.sxt;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class LoginFrame extends JFrame{
JTextField txtname=new JTextField();
JPasswordField txtpass=new JPasswordField();
JButton bl=new JButton("登录");
JButton bg=new JButton("关闭");
//构造无参构造器把主要的方法放在构造器里,然后在main方法里面调
public LoginFrame(){
setBounds(25,25,250,250);
Container c = getContentPane();
c.setLayout(new GridLayout(4,2,10,10));
c.add(new JLabel("用户名"));
c.add(txtname);
c.add(new JLabel("密码"));
c.add(txtpass);
c.add(bl);
c.add(bg);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
//注意:此处是匿名内部类
bg.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
}
);
//注意:此处是匿名内部类
bl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {