
正文
java写课程表代码 课程表jsp代码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
有没有大佬会用Java制作一个课程表?
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Vector;
public class Scholl_Timetble {
static String[] RequiredCourse = { "语文", "数学", "英语", "历史", "政治", "地理", "化学", "物理", "生物" };
static String[] Elective = { "体育", "音乐", "美术" };
static VectorInteger vectorElective = new Vector();
// 随机选修课数组索引集合
static VectorInteger vectorRequiredCourse = new Vector();
// 随机必修课数组索引集合
static VectorInteger vectorDay = new Vector();
// 随机天集合
static VectorInteger vectorLession = new Vector();
// 随机课集合
static VectorInteger vectorRequiredCourse() {
// 随机必修课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
if (!linkedHashSet.isEmpty()) {
linkedHashSet.clear();
}
while (linkedHashSet.size() RequiredCourse.length) {
linkedHashSet.add((int) (Math.random() * RequiredCourse.length));
}
linkedHashSet.forEach(x - vectorRequiredCourse.add(x));
return vectorRequiredCourse;
}
static VectorInteger vectorElective() {
// 随机选修课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (Math.random() * Elective.length));
}
linkedHashSet.forEach(x - vectorElective.add(x));
return vectorElective;
}
static VectorInteger vectorDay() {
// 随机天方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (1 + Math.random() * 5));
}
linkedHashSet.forEach(x - vectorDay.add(x));
return vectorDay;
}
static VectorInteger vectorLession() {
// 随机课方法
LinkedHashSetInteger linkedHashSet = new LinkedHashSet();
while (linkedHashSet.size() Elective.length) {
linkedHashSet.add((int) (1 + Math.random() * 7));
}
linkedHashSet.forEach(x - vectorLession.add(x));
return vectorLession;
}
public static void main(String[] args) {
String s[] = { "一", "二", "三", "四", "五" };
vectorDay();
Collections.sort(vectorDay);
vectorLession();
Collections.sort(vectorLession);
vectorElective();
for (int i1 = 1; i1 6; i1++) {
vectorRequiredCourse();
for (int i = 1; i 8; i++) {
if (i == 1)
System.out.print("\n周" + s[i1 - 1] + "\t");
int i2 = 0;
for (int i3 = 0; i3 vectorElective.size(); i3++) {
if (vectorDay.get(i3) == i1 vectorLession.get(i3) == i) {
System.out.print(Elective[vectorElective.get(i3)] + "\t");
break;
} else if (i2 == vectorElective.size() - 1) {
System.out.print(RequiredCourse[vectorRequiredCourse.get(i - 1)] + "\t");
}
i2++;
}
}
System.out.println();
vectorRequiredCourse.removeAllElements();
}
}
}
这个课程表每天无重复课程,如果要想有重复的需要加条件
相关问答
Q1: java课程设计题目及代码是什么?
java课程设计题目及代码分别是:
1、题目:计算器。设计内容是设计一个图形界面(GUI)的计算器应用程序,完成简单的算术运算。
设计要求是设计的计算器应用程序可以完成家法、减法、乘法、除法和取余运算。且有小数点、正负号、求倒数、退格和清零功能。
2、代码:
数字按钮NumberButton类如下:
import java.awt.
import java.awt.event.
import javax.swing.
public class NumberButton extends Button.
{
int number.
public NumberButton(int number).
{
super(""+number).
this.number=number.
setForeground(Color.blue).
}
public int getNumber().
{
return number;
}
}
其它java课程设计题目及代码是:
题目:华容道。编写一个按钮的子类,使用该子类创建的对象代表华容道中的人物。通过焦点事件控制人物颜色,当人物获得焦点时颜色为蓝色,当失去焦点时颜色为灰色。
通过键盘事件和鼠标事件来实现曹操、关羽等人物的移动。当人物上发生鼠标事件或键盘事件时,如果鼠标指针的位置是在人物的下方(也就是组件的下半部分)或按下键盘的“↓“键,该人物向下移动。向左、向右和向上的移动原理类似。
代码是:
String name[]={"曹操","关羽","张","刘","马","许","兵","兵","兵","兵"}.
for(int i=0;iname.length;i++).
{
person[i]=new Person(i,name[i]).
person[i].addKeyListener(this).
person[i].addMouseListener(this).
// person[i].addFocusListener(new Person).
add(person[i]).
}
person[0].setBounds(104,54,100,100).
person[1].setBounds(104,154,100,50).
person[2].setBounds(54,154,50,100).
person[3].setBounds(204,154,50,100).
person[4].setBounds(54,54,50,100).
person[5].setBounds(204,54,50,100);
person[6].setBounds(54,254,50,50);
person[7].setBounds(204,254,50,50);
person[8].setBounds(104,204,50,50);
person[9].setBounds(154,204,50,50);
Q2: 请帮我用JAVA数组的方式编写一个课程表,感激不尽!
public class IdUtil {
public static void main(String[] args) {
//七天java写课程表代码的课程
String[] week = new String[7];
//每天java写课程表代码的课程名
week[0] = "语文,语文,语文,语文,语文,语文,语文,语文,语文,语文";
week[1] = "数学,数学,数学,数学,数学,数学,数学,数学,数学,数学";
week[2] = "外语,外语,外语,外语,外语,外语,外语,外语,外语,外语";
week[3] = "物理,物理,物理,物理,物理,物理,物理,寂寞学,物理,物理";
week[4] = "化学,化学,化学,化学,化学,化学,化学,化学,化学,化学";
week[5] = "生物,生物,生物,生物,生物,生物,生物,生物,生物,生物";
week[6] = "寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学";
//上课时间
String[] time = {"8:00","9:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00"};
for(int a=1;a8;a++){
System.out.print("\t"+"星期"+a);
}
System.out.println();
int b = 0;
for(int i=1;i11;i++){
switch (i) {
case 1:
System.out.println("上午");
break;
case 5:
System.out.println("下午");
break;
case 9:
System.out.println("晚上");
break;
}
System.out.print(time[i-1]+"\t");
for(int j=0;j7;j++){
System.out.print(week[j].split(",")[b]+"\t");
}
System.out.println();
b++;
}
}
}
Q3: 用java实现课程表
java写课程表代码你只需要一个选课表,存学生ID,课程ID,所有学生的选课都是这一个表,每次选课加一条数据,展现的时候根据用户去查选课表就行java写课程表代码了
Q4: 用JAVA编写一个课程类Cource
编写Cource
/**
* 一、编写一个课程类Course,包含:
* 1、3个私有成员变量:课程编号(cNumber)、课程名(cName)和学分数(cUnit);
* 2、1个构造器方法:带3个参数的构造器方法,用于初始化课程编号、课程名和学分。
* 3、成员方法:(1)cNumber 、cName、cUnit属性的set和get方法
* (2)printCourceInfo:用于输出课程的相关信息;
* 4、编写Cource类的测试程序,创建课程对象:编号为070401,课程名为Java程序设计,学分为4。要求输出课
*/
public class Course {
private int cNumber;
private String cName;
private int cUnit;
public Course(int cNumber, String cName, int cUnit) {
this.cNumber = cNumber;
this.cName = cName;
this.cUnit = cUnit;
}
public void setcNumber(int cNumber) {
this.cNumber = cNumber;
}
public void setcName(String cName) {
this.cName = cName;
}
public void setcUnit(int cUnit) {
this.cUnit = cUnit;
}
public int getcNumber() {
return cNumber;
}
public String getcName() {
return cName;
}
public int getcUnit() {
return cUnit;
}
public void printCourseInfo() {
System.out.println("课程编号: " + cNumber + " 课程名" + cName + " 学分数" + cUnit);
}
}
编写测试类
public class TestCourse{
public static void main(String[] args){
Course course=new Course(070401,"Java程序设计",4);
course.printCourseInfo();
}
}
代码是AndroidStudio里写的。测试不了~不过肯定没错的(吧~)
用IDE写的话可以直接生成get set 和构造函数的。这种代码都不怎么需要写的。不过如果是新手的话写多点没坏处。
Q5: java课程设计源代码(急!!!!)
import java.awt.Color;
import java.awt.Font;
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.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
public class game21 extends JFrame {
private JLabel label_2;
private int number;
private int sum;
final JLabel label = new JLabel();
final JLabel label_1 = new JLabel();
public static void main(String[] args) {
new game21();
}
public game21() {
super("21点?!");
getContentPane().setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JButton button = new JButton();
button.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent arg0) {
onClick();
}
});
button.setText("出牌");
button.setBounds(170, 350, 106, 28);
getContentPane().add(button);
label.setBorder(new LineBorder(Color.black, 1, false));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("", Font.BOLD, 26));
label.setText("背面");
label.setBounds(158, 81, 137, 153);
getContentPane().add(label);
label_1.setText("java写课程表代码你已经拥有的牌:");
label_1.setBounds(109, 22, 270, 45);
getContentPane().add(label_1);
this.setBounds(200, 300, 501, 528);
this.setVisible(true);
getContentPane().add(getLabel_2());
}
public int randNumber() {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
return (int) (Math.random() * 10 + 1);
}
public void onClick() {
number = this.randNumber();
this.sum += number;
label.setText("" + number);
String strTemp = this.label_1.getText();
strTemp += "" + number + " ";
label_1.setText(strTemp);
String temp = "合计java写课程表代码:" + sum;
label_2.setText(temp);
isWin();
}
public void isWin() {
if (sum 21) {
JOptionPane.showMessageDialog(this, "你输了");
clear();
return;
} else if (sum == 21) {
JOptionPane.showMessageDialog(this, "你赢了");
clear();
return;
} else {
int i = JOptionPane.showOptionDialog(this, "是否继续?", "提示",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, null, null);
if (i == JOptionPane.OK_OPTION) {
onClick();
} else
return;
}
}
private void clear() {
label_2.setText("合计:");
sum = 0;
number = 0;
label_1.setText("你已经拥有的牌:");
}
/**
* @return
*/
protected JLabel getLabel_2() {
if (label_2 == null) {
label_2 = new JLabel();
label_2.setText("合计:");
label_2.setBounds(313, 35, 66, 18);
}
return label_2;
}
}
真好无聊中。。
java写课程表代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于课程表jsp代码、java写课程表代码的信息别忘了在本站进行查找喔。






