0/100
weixin_45351817
数据库的基本语句1
创建一个name表
create table student(
name varchar(30),
id int,
score double,
classname varchar(10)
);
查询user类
select * from user;
插入语句
insert into user (name,pwd)
values(‘小张’,‘999’);
– 条件查询
select * from user where name=‘小红’;
– 修改
update user set pwd=‘5555’ where name=‘小红’;
– 删除
delete from user where name=‘小张’;
Java程序设计
设计一个学生作业管理系统
创建一个Student类
public class Student {
private String name;
private String name11;
int number;
public String getName11() {
return name11;
}
public void setName11(String name11) {
this.name11 = name11;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
创建一个Teacher类
package com.base.day700;
public class Teacher {
private String name;
private Homework work;
public Homework getWork() {
return work;
}
public void setWork(Homework work) {
this.work = work;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
创建一个Homework类
public class Homework {
private Student student;
private String workname;
private int point;
private String grade;
private String Comment;
private Teacher teakher;
public String getComment() {
return Comment;
}
public void setComment(String comment) {
Comment = comment;
}
public Teacher getTeakher() {
return teakher;
}
public void setTeakher(Teacher teakher) {
this.teakher = teakher;
}
public String getWorkname() {
return workname;
}
public void setWorkname(String workname) {
this.workname = workname;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public int getPoint() {
return point;
}
public void setPoint(int point) {
this.point = point;
}
}
方法类
package com.base.day700;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class Controller {
static ArrayList orderlist=new ArrayList();
public static void sethomework(Student a,String workname){
Date d=new Date();
Homework b=new Homework();
b.setStudent(a);
b.setWorkname(workname);
orderlist.add(b);
System.out.println(a.getName()+"学号"+a.getNumber()+"已提交"+b.getWorkname());
SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd");
System.out.println("提交时间"+s.format(d));
}
public static void homeworkcorrecting(Teacher teacher,String grade,String Comment){
//int [] Score =new int[];
Homework o=(Homework) orderlist.get(orderlist.size()-1);
o.setGrade(grade);
o.setComment(Comment);
int a = 0;
if(grade.equals("A")){
a=5;
}else if(grade.equals("B")){
a=3;
}else if(grade.equals("C")){
a=2;
}else if(grade.equals("D")){
a=1;
}else {
System.out.println("错误");
}
//Score[orderlist.size()-1]=a;
o.setPoint(a);
System.out.println(teacher.getName()+"老师的评价是 "+o.getComment()+" 获得了 "+o.getGrade()+" 等级 "+o.getPoint()+" 分");
System.out.println();
}
public static void sort(){
int temp = 0;
String temp1 = "0";
int [] Score =new int[orderlist.size()];
String [] name =new String[orderlist.size()];
System.out.println("按成绩排序");
for(int i=0;i<orderlist.size();i++){
Homework o=(Homework) orderlist.get(i);
Score[i]=o.getPoint();
name[i]=o.getStudent().getName();
}
for (int j = 0; j < Score.length; j++) {
//对每一个数组元素,从0到还未来排序的最大下标,总是把最大的数字放在后面
for (int k = 0; k < Score.length - j -1; k++) {
if (Score[k] < Score[k + 1]) { //判断当前数字与后面数字的大小
temp = Score[k];
temp1 = name[k];
Score[k] = Score[k + 1];
name[k] = name[k+1];
Score[k + 1] = temp; //用temp变量进行换值
name[k + 1] = temp1; //用temp变量进行换值
}
}
}
//System.out.print(name[1] + " ");
for (int i = 0; i < Score.length; i++) { //遍历
System.out.print(name[i] + " "); //打印,以空格隔开
}
//换行
System.out.println();
}
}
测试类
package com.base.day700;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student student=new Student();
student.setName("小明");
student.setNumber(1001);
String workname=("数学");
Controller.sethomework(student,workname);
Teacher teacher=new Teacher();
teacher.setName("王");
String grade=("C");
String Comment=("加油");
Controller.homeworkcorrecting(teacher,grade,Comment);
Student student0=new Student();
student0.setName("小张");
student0.setNumber(1000);
String workname0=("大英");
Controller.sethomework(student0,workname0);
Teacher teacher0=new Teacher();
teacher0.setName("李");
String grade0=("B");
String Comment0=("可以");
Controller.homeworkcorrecting(teacher0,grade0,Comment0);
Student student1=new Student();
student1.setName("小红");
student1.setNumber(1002);
String workname1=("大物");
Controller.sethomework(student1,workname1);
Teacher teacher1=new Teacher();
teacher1.setName("张");
String grade1=("A");
String Comment1=("优秀");
Controller.homeworkcorrecting(teacher1,grade1,Comment1);
Controller.sort();
}
}
数据库的基本语句1
创建一个name表
create table student(
name varchar(30),
id int,
score double,
classname varchar(10)
);
查询user类
select * from user;
插入语句
insert into user (name,pwd)
values(‘小张’,‘999’);
– 条件查询
select * from user where name=‘小红’;
– 修改
update user set pwd=‘5555’ where name=‘小红’;
– 删除
delete from user where name=‘小张’;
Java程序设计
设计一个学生作业管理系统
创建一个Student类
public class Student {
private String name;
private String name11;
int number;
public String getName11() {
return name11;
}
public void setName11(String name11) {
this.name11 = name11;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
创建一个Teacher类
package com.base.day700;
public class Teacher {
private String name;
private Homework work;
public Homework getWork() {
return work;
}
public void setWork(Homework work) {
this.work = work;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
创建一个Homework类
public class Homework {
private Student student;
private String workname;
private int point;
private String grade;
private String Comment;
private Teacher teakher;
public String getComment() {
return Comment;
}
public void setComment(String comment) {
Comment = comment;
}
public Teacher getTeakher() {
return teakher;
}
public void setTeakher(Teacher teakher) {
this.teakher = teakher;
}
public String getWorkname() {
return workname;
}
public void setWorkname(String workname) {
this.workname = workname;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public int getPoint() {
return point;
}
public void setPoint(int point) {
this.point = point;
}
}
方法类
package com.base.day700;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class Controller {
static ArrayList orderlist=new ArrayList();
public static void sethomework(Student a,String workname){
Date d=new Date();
Homework b=new Homework();
b.setStudent(a);
b.setWorkname(workname);
orderlist.add(b);
System.out.println(a.getName()+"学号"+a.getNumber()+"已提交"+b.getWorkname());
SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd");
System.out.println("提交时间"+s.format(d));
}
public static void homeworkcorrecting(Teacher teacher,String grade,String Comment){
//int [] Score =new int[];
Homework o=(Homework) orderlist.get(orderlist.size()-1);
o.setGrade(grade);
o.setComment(Comment);
int a = 0;
if(grade.equals("A")){
a=5;
}else if(grade.equals("B")){
a=3;
}else if(grade.equals("C")){
a=2;
}else if(grade.equals("D")){
a=1;
}else {
System.out.println("错误");
}
//Score[orderlist.size()-1]=a;
o.setPoint(a);
System.out.println(teacher.getName()+"老师的评价是 "+o.getComment()+" 获得了 "+o.getGrade()+" 等级 "+o.getPoint()+" 分");
System.out.println();
}
public static void sort(){
int temp = 0;
String temp1 = "0";
int [] Score =new int[orderlist.size()];
String [] name =new String[orderlist.size()];
System.out.println("按成绩排序");
for(int i=0;i<orderlist.size();i++){
Homework o=(Homework) orderlist.get(i);
Score[i]=o.getPoint();
name[i]=o.getStudent().getName();
}
for (int j = 0; j < Score.length; j++) {
//对每一个数组元素,从0到还未来排序的最大下标,总是把最大的数字放在后面
for (int k = 0; k < Score.length - j -1; k++) {
if (Score[k] < Score[k + 1]) { //判断当前数字与后面数字的大小
temp = Score[k];
temp1 = name[k];
Score[k] = Score[k + 1];
name[k] = name[k+1];
Score[k + 1] = temp; //用temp变量进行换值
name[k + 1] = temp1; //用temp变量进行换值
}
}
}
//System.out.print(name[1] + " ");
for (int i = 0; i < Score.length; i++) { //遍历
System.out.print(name[i] + " "); //打印,以空格隔开
}
//换行
System.out.println();
}
}
测试类
package com.base.day700;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student student=new Student();
student.setName("小明");
student.setNumber(1001);
String workname=("数学");
Controller.sethomework(student,workname);
Teacher teacher=new Teacher();
teacher.setName("王");
String grade=("C");
String Comment=("加油");
Controller.homeworkcorrecting(teacher,grade,Comment);
Student student0=new Student();
student0.setName("小张");
student0.setNumber(1000);
String workname0=("大英");
Controller.sethomework(student0,workname0);
Teacher teacher0=new Teacher();
teacher0.setName("李");
String grade0=("B");
String Comment0=("可以");
Controller.homeworkcorrecting(teacher0,grade0,Comment0);
Student student1=new Student();
student1.setName("小红");
student1.setNumber(1002);
String workname1=("大物");
Controller.sethomework(student1,workname1);
Teacher teacher1=new Teacher();
teacher1.setName("张");
String grade1=("A");
String Comment1=("优秀");
Controller.homeworkcorrecting(teacher1,grade1,Comment1);
Controller.sort();
}
}
Markdown 4381 字数 270 行数 当前行 267, 当前列 0
HTML 4280 字数 217 段落