java写课程表代码 课程表jsp代码( 三 )


*/
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 和构造函数的 。这种代码都不怎么需要写的 。不过如果是新手的话写多点没坏处 。
java课程设计源代码(急?。。。。?/h2>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 (sum21) {
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);

推荐阅读