當前位置:首頁 » 課程大全 » 大學java簡單課程設計

大學java簡單課程設計

發布時間: 2021-03-06 06:58:46

㈠ 求java程序!!!大一的java課程設計題目,求高手送程序~~~求大家幫忙啊~~~

完整的Java程序:

public class Test32 {
public static void main(String[] args) {
c1 = new Complex(2, -1);
Complex c2 = new Complex(3, 4);
int m = 3;
System.out.println(c1.toString() + "的絕對值:" + c1.abs());
System.out.println(c1.toString() + "自增後:" + c1.addBySelf());
System.out.println(c1.toString() + "自減後:" + c1.subtractBySelf());
System.out.println("(" + c1.toString() + ") + (" + c2.toString() + ") = " + c1.add(c2));
System.out.println("(" + c1.toString() + ") - (" + c2.toString() + ") = " + c1.subtract(c2));
System.out.println("(" + c1.toString() + ") * (" + c2.toString() + ") = " + c1.multiply(c2));
System.out.println("(" + c1.toString() + ") / (" + c2.toString() + ") = " + c1.divide(c2));
System.out.println(c1.toString() + "的" + m + "次方 = " + c1.power(m));
}
}

//復數類:初始化復數、求其絕對值、復數的加、減、乘、除、乘方、自加、自減
class Complex{
protected double real; //實部
protected double image; //虛部

public Complex(){
real = image = 0;
}

public Complex(double real, double image){
this.real = real;
this.image = image;
}

//復數的絕對值
public Complex abs(){
return new Complex(Math.abs(this.real), Math.abs(this.image));
}

//復數相加
public Complex add(Complex c){
return new Complex(this.real + c.real, this.image + c.image);
}

//復數相減
public Complex subtract(Complex c){
return new Complex(this.real - c.real, this.image - c.image);
}

//復數相乘
public Complex multiply(Complex c){
return new Complex(this.real * c.real - this.image * c.image,
this.real * c.image + this.image * c.real);
}

//復數相除
public Complex divide(Complex c){
return new Complex((this.real * c.real + this.image * c.image) / (c.real * c.real + c.image * c.image),
(this.image * c.real - this.real * c.image) / (c.real * c.real + c.image * c.image));
}

//復數乘方
public Complex power(int m){
if(m < 0)
return new Complex();
if(m == 0)
return new Complex(1, 0);

Complex c = this;
for(int i=1; i<m; i++){
c = c.multiply(this);
}

return c;
}

//復數自增
public Complex addBySelf(){
return new Complex(++this.real, ++this.image);
}

//復數自減
public Complex subtractBySelf(){
return new Complex(--this.real, --this.image);
}

public String toString(){
if(this.real == 0)
if(this.image == 0)
return "0";
else
return this.image + "i";
else
if(this.image == 0)
return this.real + "";
else if(this.image > 0)
return this.real + "+" + this.image + "i";
else
return this.real + "" + this.image + "i";
}
}

運行測試:
2.0-1.0i的絕對值:2.0+1.0i
2.0-1.0i自增後:3.0
3.0自減後:2.0-1.0i
(2.0-1.0i) + (3.0+4.0i) = 5.0+3.0i
(2.0-1.0i) - (3.0+4.0i) = -1.0-5.0i
(2.0-1.0i) * (3.0+4.0i) = 10.0+5.0i
(2.0-1.0i) / (3.0+4.0i) = 0.08-0.44i
2.0-1.0i的3次方 = 2.0-11.0i

㈡ Java課程設計,畢業設計怎麼做

可以用它做一個網站當畢業設計,需要的可以私聊我

㈢ 求java課程設計,做個簡單的應用程序

啥程序,說出來看看

㈣ 比較簡單的java課程設計代碼

我們上個星期是實踐周,我剛剛做完一個掃雷小游戲,如果想要請留下郵箱,我發過去。

㈤ !高分跪求幫忙寫一個簡單小程序的JAVA課程設計報告(內詳!!)

連連看java源代碼
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數組
JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕
JLabel fractionLable=new JLabel("0"); //分數標簽
JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕
int grid[][] = new int[8][7];//儲存游戲按鈕位置
static boolean pressInformation=false; //判斷是否有按鈕被選中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標
int i,j,k,n;//消除方法控制
public void init(){
mainFrame=new JFrame("JKJ連連看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel=new JPanel();
southPanel=new JPanel();
northPanel=new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6,5));
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}
exitButton=new JButton("退出");
exitButton.addActionListener(this);
resetButton=new JButton("重列");
resetButton.addActionListener(this);
newlyButton=new JButton("再來一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));
northPanel.add(fractionLable);
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
public void randomBuild() {
int randoms,cols,rows;
for(int twins=1;twins<=15;twins++) {
randoms=(int)(Math.random()*25+1);
for(int alike=1;alike<=2;alike++) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=randoms;
}
}
}
public void fraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));
}
public void reload() {
int save[] = new int[30];
int n=0,cols,rows;
int grid[][]= new int[8][7];
for(int i=0;i<=6;i++) {
for(int j=0;j<=5;j++) {
if(this.grid[i][j]!=0) {
save[n]=this.grid[i][j];
n++;
}
}
}
n=n-1;
this.grid=grid;
while(n>=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=save[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false; //這里一定要將按鈕點擊信息歸為初始
init();
for(int i = 0;i < 6;i++){
for(int j = 0;j < 5;j++ ){
if(grid[i+1][j+1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
public void estimateEven(int placeX,int placeY,JButton bz) {
if(pressInformation==false) {
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
pressInformation=true;
}
else {
x0=x;
y0=y;
fristMsg=secondMsg;
firstButton=secondButton;
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
if(fristMsg==secondMsg && secondButton!=firstButton){
xiao();
}
}
}
public void xiao() { //相同的情況下能不能消去。仔細分析,不一條條注釋
if((x0==x &&(y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)&&(y0==y))){ //判斷是否相鄰
remove();
}
else{
for (j=0;j<7;j++ ) {
if (grid[x0][j]==0){ //判斷第一個按鈕同行哪個按鈕為空
if (y>j) { //如果第二個按鈕的Y坐標大於空按鈕的Y坐標說明第一按鈕在第二按鈕左邊
for (i=y-1;i>=j;i-- ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0) {
k=0;
break;
}
else{ k=1; } //K=1說明通過了第一次驗證
}
if (k==1) {
linePassOne();
}
}
if (y<j){ //如果第二個按鈕的Y坐標小於空按鈕的Y坐標說明第一按鈕在第二按鈕右邊
for (i=y+1;i<=j ;i++ ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0){
k=0;
break;
}
else { k=1; }
}
if (k==1){
linePassOne();
}
}
if (y==j ) {
linePassOne();
}
}
if (k==2) {
if (x0==x) {
remove();
}
if (x0<x) {
for (n=x0;n<=x-1;n++ ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x-1) {
remove();
}
}
}
if (x0>x) {
for (n=x0;n>=x+1 ;n-- ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x+1) {
remove();
}
}
}
}
}
for (i=0;i<8;i++ ) { //列
if (grid[i][y0]==0) {
if (x>i) {
for (j=x-1;j>=i ;j-- ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x<i) {
for (j=x+1;j<=i;j++ ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x==i) {
rowPassOne();
}
}
if (k==2){
if (y0==y) {
remove();
}
if (y0<y) {
for (n=y0;n<=y-1 ;n++ ) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y-1) {
remove();
}
}
}
if (y0>y) {
for (n=y0;n>=y+1 ;n--) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y+1) {
remove();
}
}
}
}
}
}
}
public void linePassOne(){
if (y0>j){ //第一按鈕同行空按鈕在左邊
for (i=y0-1;i>=j ;i-- ){ //判斷第一按鈕同左側空按鈕之間有沒按鈕
if (grid[x0][i]!=0) {
k=0;
break;
}
else { k=2; } //K=2說明通過了第二次驗證
}
}
if (y0<j){ //第一按鈕同行空按鈕在與第二按鈕之間
for (i=y0+1;i<=j ;i++){
if (grid[x0][i]!=0) {
k=0;
break;
}
else{ k=2; }
}
}
}
public void rowPassOne(){
if (x0>i) {
for (j=x0-1;j>=i ;j-- ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
if (x0<i) {
for (j=x0+1;j<=i ;j++ ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
}
public void remove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==newlyButton){
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation=false;
init();
}
if(e.getSource()==exitButton)
System.exit(0);
if(e.getSource()==resetButton)
reload();
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);
}
}
}
public static void main(String[] args) {
lianliankan llk = new lianliankan();
llk.randomBuild();
llk.init();
}
}

//old 998 lines
//new 318 lines
參考資料:http://..com/question/36439800.html?fr=qrl3

㈥ 求一個最最簡單的java課程設計報告

JAVA課程設計黑白棋源代回碼答
www.lwfree.cn/Article/sheji/200709/58.html

㈦ 一個很簡單的java課設...

自己不會還來一個很簡單的畢設,難道不矛盾嗎?

㈧ JAVA課程設計--簡易計算器. 求源代碼.

import javax.swing.*;//新的窗口組件包
import java.awt.*;
import java.awt.event.*;
public class Jisuanqi implements ActionListener
{ JFrame jf=new JFrame();
boolean dotExist, operated, equaled; // 幫助運算的布爾變數
double result; // 目前的結果
char lastOperator; // 表示上一運算符
JTextField jtf; // 顯示欄
JButton dot, plus, minus, multi, div, sqrt, equal, change, clear,quyu; // 運算符
JButton[] numbers;
Panel p=new Panel();
// 構造者
public Jisuanqi()
{
jf.setTitle("陳巳偉牌計算器");
// 初始化變數
dotExist = false; // 表示當前的數是否有小數點
operated = false; // 表示任意運算符是否被按下
equaled = false; // 表示等號是否被按下
result = 0;
lastOperator = '?';
// 初始化窗口變數
jtf = new JTextField("0");
jtf.setEditable(false); //設置文本框的可編輯性
jf.setSize(250,200);
jf.setVisible(true);
numbers = new JButton[10];
for (int i = 0; i < 10; i++)
numbers[i] = new JButton("" + i);
dot = new JButton(".");
plus = new JButton("+");
minus = new JButton("-");

multi = new JButton("*");
div = new JButton("/");
sqrt = new JButton("√");
equal = new JButton("=");
change= new JButton("±");
clear = new JButton("NC");
quyu=new JButton("%");

p.setLayout(new GridLayout(5,4));
p.add(numbers[1]);
p.add(numbers[2]);
p.add(numbers[3]);
p.add(plus);
p.add(numbers[4]);
p.add(numbers[5]);
p.add(numbers[6]);
p.add(minus);
p.add(numbers[7]);
p.add(numbers[8]);
p.add(numbers[9]);
p.add(multi);
p.add(dot);
p.add(numbers[0]);
p.add(sqrt);
p.add(div);
p.add(equal);
p.add(change);
p.add(clear);
p.add(quyu);
jf.add(jtf,BorderLayout.NORTH);
jf.add(p,BorderLayout.CENTER);
numbers[0].addActionListener(this);
numbers[1].addActionListener(this);
numbers[2].addActionListener(this);
numbers[3].addActionListener(this);
plus.addActionListener(this);
numbers[4].addActionListener(this);
numbers[5].addActionListener(this);
numbers[6].addActionListener(this);
minus.addActionListener(this);
numbers[7].addActionListener(this);
numbers[8].addActionListener(this);
numbers[9].addActionListener(this);
multi.addActionListener(this);
dot.addActionListener(this);
sqrt.addActionListener(this);
div.addActionListener(this);
equal.addActionListener(this);
change.addActionListener(this);
clear.addActionListener(this);
quyu.addActionListener(this);

}
// 對按鈕進行反應的方法
public void actionPerformed(ActionEvent e)
{
JButton btn = (JButton)e.getSource();
if (btn == clear)
{
jtf.setText("0");
dotExist = false;
operated = false;
equaled = false;
result = 0;
lastOperator = '?';
}
else if (btn == equal)
{
operate('=');
equaled = true;
}
else if (btn == plus)
{
operate('+');
equaled = false;
}
else if (btn == minus)
{
operate('-');
equaled = false;
}
else if (btn == multi)
{
operate('*');
equaled = false;
}
else if (btn == div)
{
operate('/');
equaled = false;
}
else if (btn==quyu){
operate('%');
equaled=false;
}
else if (btn == change)
{
operate('p');
operate('=');
equaled = true;
}
else if (btn == sqrt)
{
operate('s');
operate('=');
equaled = true;
}
else
{
if (equaled)
result = 0;
for (int i = 0; i < 10; i++)
if (btn == numbers[i])
{
if (jtf.getText().equals("0"))
jtf.setText("" + i);
else if(! operated)
jtf.setText(jtf.getText() + i);
else
{
jtf.setText("" + i);
operated = false;
}
}
if (btn == dot && ! dotExist)
{
jtf.setText(jtf.getText() + ".");

}
}
}
// 進行運算的方法
private void operate(char operator)
{
double currentNumber = Double.valueOf(jtf.getText()).doubleValue();
if (lastOperator == '?')
result = currentNumber;
else if (lastOperator == '+')
result += currentNumber;
else if (lastOperator == '-')
result -= currentNumber;
else if (lastOperator == '*')
result *= currentNumber;
else if (lastOperator == '/')
result /= currentNumber;
else if(lastOperator=='%')
result %=currentNumber;
else if (lastOperator == 'p')
result *= -1;
else if (lastOperator == 's')
result = Math.sqrt(currentNumber);
else if (lastOperator == '=' && equaled)
result = currentNumber;
jtf.setText("" + result);
operated = true;
lastOperator = operator;
}

public static void main(String[] args)
{new Jisuanqi();<br> <br> }
}

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919