當前位置:首頁 » 編程語言 » java設計報告

java設計報告

發布時間: 2025-09-21 10:32:40

java程序設計實驗報告 繼承與多態

package MyShape;


public class Test {


/**

* @param args

*/

public static void main(String[] args) {

Circle c = new Circle(2,4,3);

c.printItMyWay();

}


}

abstract class Shape{

public abstract float getCir();

public abstract float getArea();

}

class Point extends Shape implements Printable{

public int x;

public int y;

public Point(int x, int y){

this.x= x;

this.y=y;

}

public Point (){

}


@Override

public float getCir() {

// TODO Auto-generated method stub

return 0;

}

@Override

public float getArea() {

// TODO Auto-generated method stub

return 0;

}

public int getX() {

return x;

}

public void setX(int x) {

this.x = x;

}

public int getY() {

return y;

}

public void setY(int y) {

this.y = y;

}

@Override

public void printItMyWay() {

System.out.println(" Point ("+x+","+y+")");

System.out.println(" Point Area:"+this.getArea());

System.out.println(" Point Circle:"+this.getCir());

}

}


class Circle extends Point implements Printable{

public float r ;

public Circle(){

}

public Circle(float r,int x, int y ){

if(r>0){

this.r =r;

this.x =x;

this.y=y;

}

}

public float getR() {

return r;

}

public void setR(float r) {

this.r = r;

}

@Override

public float getArea() {

return (float) (r*r*3.14/2);

}

@Override

public float getCir() {

return (float) (3.14*r*2);

}

@Override

public void printItMyWay() {

System.out.println(" Circle ("+x+","+y+")");

System.out.println(" Circle R:"+r);

System.out.println(" Circle Area:"+this.getArea());

System.out.println(" Circle Circle:"+this.getCir());

}

}


interface Printable {

public void printItMyWay();

}

❷ java 計算器課程設計報告

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;//導包

class MyClass extends JFrame
//創建一個MyClass類繼承JFrame框架的窗口類,
//也就是說JFrame里有的功能MyClass都能實現
{
JLabel a1=new JLabel("第一個數");
//創建一個顯示「第一個數」的標簽
JLabel a2=new JLabel("第二個數");
JLabel a3=new JLabel("運算結果");
JTextField b1=new JTextField(5);
//創建一個文本框、默認長度為5,用來輸入運算數字,當然也可以默認為空
JTextField b2=new JTextField(5);
JTextField b3=new JTextField(5);
//創建一個用於顯示運算結果的標簽,也可以創建一個標簽來顯示
JButton a=new JButton("加");
//創建一個用於加法計算的按鈕,點擊時進行加法運算
JButton b=new JButton("減");
JButton c=new JButton("乘");
JButton d=new JButton("除");
JPanel jp1=new JPanel();//創建一個面板,用來放控制項
JPanel jp2=new JPanel();
JPanel jp3=new JPanel();
MyClass()//構造函數,用來初始化的
{
setLayout(new GridLayout(3,1));//添加一個四行四列的布局管理器
jp1.setLayout(new FlowLayout());//設置JP1面板為流式布局管理器
jp1.setLayout(new FlowLayout());
//將a1,b1,a2,b2四個控制項添加到jp1面板中
jp1.add(a1);
jp1.add(b1);
jp1.add(a2);
jp1.add(b2);
jp1.add(a3);
//將a,b,c,d四個控制項添加到jp2面板中
jp2.add(a);
jp2.add(b);
jp2.add(c);
jp2.add(d);
jp3.add(a3);
jp3.add(b3);
//將jp1,jp2,jp3三個面板添加到窗口中
add(jp1);
add(jp3);
add(jp2);
Object e;
a.addActionListener(new ActionListener()
//創建一個匿名的事件監聽器
{

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
double x=Double.valueOf(b1.getText().toString());
//獲取第一個輸入數,並將其由String型轉換成double型
double y=Double.valueOf(b2.getText().toString());
//獲取第二個輸入數,並將其由String型轉換成double型
b3.setText(""+(x+y));
//將運算結果在b3這個文本框中顯示
}

});
b.addActionListener(new ActionListener()
{

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
double x=Double.valueOf(b1.getText().toString());
double y=Double.valueOf(b2.getText().toString());
b3.setText(""+(x-y));
}

});
c.addActionListener(new ActionListener()//創建一個匿名的事件監聽器
{

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
double x=Double.valueOf(b1.getText().toString());
double y=Double.valueOf(b2.getText().toString());
b3.setText(""+(x*y));
}

});
d.addActionListener(new ActionListener()//創建一個匿名的事件監聽器
{

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
double x=Double.valueOf(b1.getText().toString());
double y=Double.valueOf(b2.getText().toString());
//因為0不能做除數,所以在這里需要進行判斷
if(y==0)
{
b3.setText("錯誤");
}
else
{
b3.setText(""+(x/y));
}
}

});
//下面的是設置窗口的屬性
this.setTitle("計算器");//設置窗口的標題
//this.setSize(400,400);//設置窗口的大小,也可以改成this.pack()
this.pack();
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);//設置關閉屬性
this.setVisible(true);//設置窗口的可見性
}
public static void main(String[] args)//主函數
{
new MyClass();
}
}

❸ 有關java開發游戲畢業設計的開題報告

首先介紹了手機游戲開發的背景、目的、意義和手機游戲開發的國內外現狀等,接著介紹了手機游戲的特徵、類型,以及手機游戲開發的基本原則等。
此外,還詳細介紹了手機游戲的開發語言Java和開發平台J2ME,講述了如何搭建J2ME平台,為讀者了解手機游戲開發和設計打下了一定的基礎,同時也講述了有關Eclipse和MIDP應用程序的一些知識。
接著在本文中介紹了手機游戲程序的結構、思想以及相關技術,主要是介紹了幾個主要的類:Canvas類和Graphics類,還有介紹了程序中的繪圖技術、混淆器的使用、模擬器的調試等。
最後本文介紹了手機游戲程序的代碼編寫和程序結構等,讓讀者對本文的手機游戲程序有了一個概括性的了解。
關鍵詞:J2ME,Java,Ecilpse,手機游戲,MIDP ABSTRACT
This article introces something about mobile telephone game.For example, the background and the objective and the meaning of it,and the developing status in in-country and out-country.And then introces the character and the style of telephone game and the basic principle of telephone game exploitation.
And then this article introces Java language and J2ME flat of telephone game exploitation, also narrate how to build J2ME flat. That would be propitious to reader to make a design.And this article also introces something about Eclipse and MIDP application in addition.
In succession,this article introces the configuration and idea and correlation technique of telephone games development.Mainly comes down to Canvas and Graphics,and plot technic in games,and how to use Obfuscator and how to debug simulator.
Finally,this article explains the code of telephone games and the program structure,readers will be understands the phone games in this article.
Keyword:J2ME,Java,Eclipse,telephone game,MIDP
目 錄
1.緒 言 5
1.1 手機游戲研究的背景 5
1.2 手機游戲研究的目的和意義 5
1.3 手機游戲的國內外現狀 6
1.4 手機游戲概述 7
1.4.1 手機游戲特徵 7
1.4.2 手機游戲的類型 8
1.4.3 手機游戲設計的基本原則 8
2.開發環境及相關技術的介紹 10
2.1 JAVA語言特點 10
2.2 J2ME概述 10
2.3 J2ME體系結構 11
2.4 關於ECLIPSE 13
2.5 J2ME開發環境的搭建 13
2.6 MIDP應用程序 14
2.7 JAVA APPLICATION MANAGER 14
3.程序結構、思想和相關技術 15
3.1 本程序需解決的有關技術問題 15
3.2 程序流程圖 15
3.3 繪圖與MIDP2.0新增的GAMECANVAS包 16
3.3.1 Canvas類 17
3.3.2 Graphics類 17
3.3.3 PNG格式 17
3.3.4 有關繪圖的一些技術 18
3.4 內存使用最佳化 18
3.5 混淆器(OBFUSCATOR)的使用 19
3.6 模擬器的調試 19
4.程序分析和編寫手機代碼 20
4.1 進入游戲前的選擇 20
4.2 主游戲邏輯及其涉及到的若干類 20
4.2.1 程序的菜單選項 20
4.2.2 游戲的設定 21
4.2.3 游戲的界面繪制 24
4.2.4 游戲中板的出現和小人位置的檢測 25
6.總結與展望 26
7.致 謝 27
參考文獻 28

熱點內容
坐標演算法 發布:2025-09-21 12:55:49 瀏覽:273
如何用安卓使用推特 發布:2025-09-21 12:54:10 瀏覽:955
王者怎麼掛機腳本 發布:2025-09-21 12:35:39 瀏覽:632
直播吧源碼 發布:2025-09-21 11:48:28 瀏覽:336
煎雞蛋解壓 發布:2025-09-21 11:47:46 瀏覽:652
安卓版ins伺服器地址 發布:2025-09-21 11:22:36 瀏覽:347
品紅試劑怎麼配置 發布:2025-09-21 11:22:14 瀏覽:889
8位手機密碼是多少 發布:2025-09-21 11:16:11 瀏覽:285
恢復微軟默認激活伺服器地址 發布:2025-09-21 11:03:01 瀏覽:42
阿里雲伺服器怎麼重置 發布:2025-09-21 10:53:11 瀏覽:114