bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

用java寫一個代碼雨 用java編寫一個程序

用JAVA編寫一個程序,要求如下:

實現代碼如下:

創新互聯公司-專業網站定制、快速模板網站建設、高性價比陳倉網站開發、企業建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式陳倉網站制作公司更省心,省錢,快速模板網站建設找我們,業務覆蓋陳倉地區。費用合理售后完善,10余年實體公司更值得信賴。

Student類:

public class Student {

private String name;

private String sex;

private int age;

private double chinese;

private double math;

private double english;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getSex() {

return sex;

}

public void setSex(String sex) {

this.sex = sex;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public double getChinese() {

return chinese;

}

public void setChinese(double chinese) {

this.chinese = chinese;

}

public double getMath() {

return math;

}

public void setMath(double math) {

this.math = math;

}

public double getEnglish() {

return english;

}

public void setEnglish(double english) {

this.english = english;

}

}

-----------------------------------------------------------------

StudentTest類:臘譽(測試類)

import java.util.Scanner;

public class StudentTest {

public static void main(String[] args) {

Student student = new Student();

Scanner sc = new Scanner(System.in);

System.out.println("請輸入姓名:");

student.setName(sc.next());

System.out.println("請輸入性別:");

student.setSex(sc.next());

System.out.println("請輸入年齡:");

student.setAge(sc.nextInt());

System.out.println("請滾衫輸入語文成績、數學成績、英語成績:");

student.setChinese(sc.nextDouble());

student.setMath(sc.nextDouble());

student.setEnglish(sc.nextDouble());

Double count = student.getChinese()+ student.getMath()+student.getEnglish();

System.out.println("姓名:"+student.getName()+" 性別:"+student.getSex()+" 年齡:"+student.getAge());

System.out.println("總分:"+count+" 平均分:"+count/3);

}

}

運行結果為大局腔:

誰幫我講解下這個java代碼

這個比較簡單,沒啥東西,就是每列開始行的選擇,有點繞彎,我就注釋下GraphicsPanel吧,主要的繪制工作都在這個類里面

private?class?GraphicsPanel?extends?JPanel?{

public?void?paint(Graphics?g)?{

Graphics2D?g2d?=?(Graphics2D)?g;

g2d.?setFont?(getFont?().?deriveFont?(Font.?BOLD));

g2d.?setColor(Color.?BLACK);

g2d.?fillRect?(0,?0,?screenSize.?width,?screenSize.?height);???//?設置背景色為黑色

int?currentColumn?=?0;

for?(int?x?=?0;?x??screenSize.width;?x?+=?gap)?{

int?endPos?=?posArr[currentColumn];??????//獲得開始行位置

g2d.?setColor(Color.?GREEN);

g2d.drawString(String.valueOf(getChr()),?x,?endPos?*?gap);?????//畫出隨機開始行的字符

int?cg?=?0;?????????????????????和明??????????????????????????????????????//初始黑色

for?(int?j?=?endPos?-16;?j??endPos;?j++)?{???????????//隨機行逐列向上16行,為循環開始行

cg?+=?15;???????碧唯??????????????????????????????????????????????//漸變色15遞增,255為green

if?(cg??255)?{

cg?=?255;

}

g2d.setColor(new?Color(0,?cg,?0));

悔棚培???????????????????g2d.drawString(String.valueOf(getChr()),?x,?j?*?gap);????//畫出隨機行后的15行字符,顏色從黑色漸變成綠色,逐行增加

}

posArr[currentColumn]?+=?random.nextInt(5);??????//下落距離最快為4

if?(posArr[currentColumn]?*?gap??getHeight())?{??//如果行數位置大于屏幕高度,從新獲取合適的行

posArr[currentColumn]?=?random.nextInt(lines);

}

currentColumn++;????//下一列獲取隨機行

}

求一個用JAVA寫的簡單的記事本源代碼程序

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.awt.datatransfer.*;

class MyMenuBar extends MenuBar{

public MyMenuBar(Frame parent){

parent.setMenuBar(this);

}

public void addMenus(String [] menus){

for(int i=0;imenus.length;i++)

add(new Menu(menus[i]));

}

public void addMenuItems(int menuNumber,String[] items){

for(int i=0;iitems.length;i++){

if(items[i]!=null)

getMenu(menuNumber).add(new MenuItem(items[i]));

else getMenu(menuNumber).addSeparator();

}

}

public void addActionListener(ActionListener al){

for(int i=0;igetMenuCount();i++)

for(int j=0;j襲禪getMenu(i).getItemCount();j++)

getMenu(i).getItem(j).addActionListener(al);

}

}

class MyFile{

private FileDialog fDlg;

public MyFile(Frame parent){

fDlg=new FileDialog(parent,"",FileDialog.LOAD);

}

private String getPath(){

return fDlg.getDirectory()+"\\"+fDlg.getFile();

}

public String getData() throws IOException{

fDlg.setTitle("打開");

fDlg.setMode(FileDialog.LOAD);

fDlg.setVisible(true);

BufferedReader br=new BufferedReader(new FileReader(getPath()));

StringBuffer sb=new StringBuffer();

String aline;

while((aline=br.readLine())!=null)

sb.append(aline+'\n');

br.close();

return sb.toString();

}

public void setData(String data) throws IOException{

fDlg.setTitle("保拍察塵沒春存");

fDlg.setMode(FileDialog.SAVE);

fDlg.setVisible(true);

BufferedWriter bw=new BufferedWriter(new FileWriter(getPath()));

bw.write(data);

bw.close();

}

}

class MyClipboard{

private Clipboard cb;

public MyClipboard(){

cb=Toolkit.getDefaultToolkit().getSystemClipboard();

}

public void setData(String data){

cb.setContents(new StringSelection(data),null);

}

public String getData(){

Transferable content=cb.getContents(null);

try{

return (String) content.getTransferData(DataFlavor.stringFlavor);

//DataFlavor.stringFlavor會將剪貼板中的字符串轉換成Unicode碼形式的String對象。

//DataFlavor類是與存儲在剪貼板上的數據的形式有關的類。

}catch(Exception ue){}

return null;

}

}

class MyFindDialog extends Dialog implements ActionListener{

private Label lFind=new Label("查找字符串");

private Label lReplace=new Label("替換字符串");

private TextField tFind=new TextField(10);

private TextField tReplace=new TextField(10);

private Button bFind=new Button("查找");

private Button bReplace=new Button("替換");

private TextArea ta;

public MyFindDialog(Frame owner,TextArea ta){

super(owner,"查找",false);

this.ta=ta;

setLayout(null);

lFind.setBounds(10,30,80,20);

lReplace.setBounds(10,70,80,20);

tFind.setBounds(90,30,90,20);

tReplace.setBounds(90,70,90,20);

bFind.setBounds(190,30,80,20);

bReplace.setBounds(190,70,80,20);

add(lFind);

add(tFind);

add(bFind);

add(lReplace);

add(tReplace);

add(bReplace);

setResizable(false);

bFind.addActionListener(this);

bReplace.addActionListener(this);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

MyFindDialog.this.dispose();

}

});

}//構造函數結束

public void showFind(){

setTitle("查找");

setSize(280,60);

setVisible(true);

}

public void showReplace(){

setTitle("查找替換");

setSize(280,110);

setVisible(true);

}

private void find(){

String text=ta.getText();

String str=tFind.getText();

int end=text.length();

int len=str.length();

int start=ta.getSelectionEnd();

if(start==end) start=0;

for(;start=end-len;start++){

if(text.substring(start,start+len).equals(str)){

ta.setSelectionStart(start);

ta.setSelectionEnd(start+len);

return;

}

}

//若找不到待查字符串,則將光標置于末尾

ta.setSelectionStart(end);

ta.setSelectionEnd(end);

}

public Button getBFind() {

return bFind;

}

private void replace(){

String str=tReplace.getText();

if(ta.getSelectedText().equals(tFind.getText()))

ta.replaceRange(str,ta.getSelectionStart(),ta.getSelectionEnd());

else find();

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==bFind)

find();

else if(e.getSource()==bReplace)

replace();

}

}

public class MyMemo extends Frame implements ActionListener{

private TextArea editor=new TextArea(); //可編輯的TextArea

private MyFile mf=new MyFile(this);//MyFile對象

private MyClipboard cb=new MyClipboard();

private MyFindDialog findDlg=new MyFindDialog(this,editor);

public MyMemo(String title){ //構造函數

super(title);

MyMenuBar mb=new MyMenuBar(this);

//添加需要的菜單及菜單項

mb.addMenus(new String[]{"文件","編輯","查找","幫助"});

mb.addMenuItems(0,new String[]{"新建","打開","保存",null,"全選"});

mb.addMenuItems(1,new String[]{"剪貼","復制","粘貼","清除",null,"全選"});

mb.addMenuItems(2,new String[]{"查找",null,"查找替換"});

mb.addMenuItems(3,new String[]{"我的記事本信息"});

add(editor); //為菜單項注冊動作時間監聽器

mb.addActionListener(this);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

MyMemo.this.dispose();

}

}); //分號不能忘了

} //構造函數完

public void actionPerformed(ActionEvent e){

String selected=e.getActionCommand(); //獲取菜單項標題

if(selected.equals("新建"))

editor.setText("");

else if(selected.equals("打開")){

try{

editor.setText(mf.getData());

}catch(IOException ie){}

}

else if(selected.equals("保存")){

try{

mf.setData(editor.getText());

}catch(IOException ie){}

}

else if(selected.equals("退出")){

dispose();

}

else if(selected.equals("剪貼")){

//將選中的字符串復制到剪貼板中并清除字符串

cb.setData(editor.getSelectedText());

editor.replaceRange("",editor.getSelectionStart(),editor.getSelectionEnd());

}

else if(selected.equals("復制")){

cb.setData(editor.getSelectedText());

}

else if(selected.equals("粘貼")){

String str=cb.getData();

editor.replaceRange(str,editor.getSelectionStart(),editor.getSelectionEnd());

//粘貼在光標位置

}

else if(selected.equals("清除")){

editor.replaceRange("",editor.getSelectionStart(),editor.getSelectionEnd());

}

else if(selected.equals("全選")){

editor.setSelectionStart(0);

editor.setSelectionEnd(editor.getText().length());

}

else if(selected.equals("查找")){

findDlg.showFind();

}

else if(selected.equals("查找替換")){

findDlg.showReplace();

}

}

public static void main(String[] args){

MyMemo memo=new MyMemo("記事本");

memo.setSize(650,450);

memo.setVisible(true);

}

}

新聞名稱:用java寫一個代碼雨 用java編寫一個程序
文章轉載:http://vcdvsql.cn/article44/ddpcgee.html

成都網站建設公司_創新互聯,為您提供網站收錄手機網站建設外貿建站服務器托管網頁設計公司

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

商城網站建設