原理上面不都有了么。。。
創(chuàng)新互聯(lián)不只是一家網(wǎng)站建設的網(wǎng)絡公司;我們對營銷、技術、服務都有自己獨特見解,公司采取“創(chuàng)意+綜合+營銷”一體化的方式為您提供更專業(yè)的服務!我們經(jīng)歷的每一步也許不一定是最完美的,但每一步都有值得深思的意義。我們珍視每一份信任,關注我們的成都網(wǎng)站建設、成都做網(wǎng)站質量和服務品質,在得到用戶滿意的同時,也能得到同行業(yè)的專業(yè)認可,能夠為行業(yè)創(chuàng)新發(fā)展助力。未來將繼續(xù)專注于技術創(chuàng)新,服務升級,滿足企業(yè)一站式成都營銷網(wǎng)站建設需求,讓再小的成都品牌網(wǎng)站建設也能產(chǎn)生價值!
好吧,我解釋一下:
d=3000 '圓的半徑
For i = 0 To 100 ‘畫100個不同半徑的圓
Circle (3200, 3200), d, RGB(255, 0, 0), 0, 3.14 ‘從點3200,3200開始畫半徑為d(3000)的半圓
d = d - 1 ‘直徑變小一個點
Next i ‘沒畫到100個圓就繼續(xù)畫
我發(fā)個畫彩虹的代碼吧,執(zhí)行結果:
代碼:
Private?Sub?Command1_Click()
d?=?3000
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(255,?0,?0),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(255,?165,?0),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(255,?255,?0),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(0,?255,?0),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(0,?127,?255),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(0,?0,?255),?0,?3.14
d?=?d?-?1
Next?i
For?i?=?0?To?100
Circle?(3200,?3200),?d,?RGB(139,?0,?255),?0,?3.14
d?=?d?-?1
Next?i
End?Sub
先定義要漸變的顏色,然后試試這個
Graphics2D g2 = (Graphics2D) g;
//繪制漸變
g2.setPaint(new GradientPaint(
0, 0, new Color(116, 149, 226),
getWidth(), getHeight(),
new Color(199, 212, 247)
));
g2.fillRect(0, 0, getWidth(), getHeight());
public class TestStar {
public static void main(String[] args) {
String star = "*";
for (int i = 0; i 5; i++) {
if (i == 0) {
System.out.print(" " + star);
System.out.println();
}
if (i == 1) {
for (int z = 0; z 4; z++) {
System.out.print(" " + star);
}
System.out.println();
}
if (i == 2) {
System.out.print(" ");
for (int x = 0; x 3; x++) {
System.out.print(" " + star);
}
System.out.println();
}
if (i == 3) {
for (int y = 0; y 2; y++) {
System.out.print(" " + star + " ");
}
}
}
}
}
是好使的 但是我沒找到畫五角星有什么規(guī)律(五角星好象不是正規(guī)圖形吧?)如果還有什么要求的話 補充問題(如果是用*填充所有的東西 不包括 “ ”的話 我可以重新再給你寫一個)
上面 wuzhikun12同學寫的不錯,但我想還不能運行,并且還不太完善。我給個能運行的:(注意:文件名為:Test.java)
//要實現(xiàn)對象間的比較,就必須實現(xiàn)Comparable接口,它里面有個compareTo方法
//Comparable最好使用泛型,這樣,無論是速度還是代碼量都會減少
@SuppressWarnings("unchecked")
class Student implements ComparableStudent{
private String studentNo; //學號
private String studentName; //姓名
private double englishScore; //英語成績
private double computerScore; //計算機成績
private double mathScore; //數(shù)學成績
private double totalScore; //總成績
//空構造函數(shù)
public Student() {}
//構造函數(shù)
public Student(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
this.studentNo = studentNo;
this.studentName = studentName;
this.englishScore = englishSocre;
this.computerScore = computerScore;
this.mathScore = mathScore;
}
//計算總成績
public double sum() {
this.totalScore = englishScore+computerScore+mathScore;
return totalScore;
}
//計算評測成績
public double testScore() {
return sum()/3;
}
//實現(xiàn)compareTO方法
@Override
public int compareTo(Student student) {
double studentTotal = student.getTotalScore();
return totalScore==studentTotal?0:(totalScorestudentTotal?1:-1);
}
//重寫toString方法
public String toString(){
return "學號:"+this.getStudentNo()+" 姓名:"+this.getStudentName()+" 英語成績:"+this.getEnglishScore()+" 數(shù)學成績:"+this.getMathScore()+" 計算機成績:"+this.getComputerScore()+" 總成績:"+this.getTotalScore();
}
//重寫equals方法
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if(!(obj instanceof Student)){
return false;
}
Student student = (Student)obj;
if(this.studentNo.equals(student.getStudentName())) { //照現(xiàn)實來說,比較是不是同一個學生,應該只是看他的學號是不是相同
return true;
} else {
return false;
}
}
/*以下為get和set方法,我個人認為,totalScore的set的方法沒必要要,因為它是由其它成績計算出來的
在set方法中,沒設置一次值,調用一次sum方法,即重新計算總成績
*/
public String getStudentNo() {
return studentNo;
}
public void setStudentNo(String studentNo) {
this.studentNo = studentNo;
sum();
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
sum();
}
public double getEnglishScore() {
return englishScore;
}
public void setEnglishScore(double englishScore) {
this.englishScore = englishScore;
sum();
}
public double getComputerScore() {
return computerScore;
}
public void setComputerScore(double computerScore) {
this.computerScore = computerScore;
sum();
}
public double getMathScore() {
return mathScore;
}
public void setMathScore(double mathScore) {
this.mathScore = mathScore;
sum();
}
public double getTotalScore() {
return totalScore;
}
}
//Student子類學習委員類的實現(xiàn)
class StudentXW extends Student {
//重寫父類Student的testScore()方法
@Override
public double testScore() {
return sum()/3+3;
}
public StudentXW() {}
//StudentXW的構造函數(shù)
public StudentXW(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//Student子類班長類的實現(xiàn)
class StudentBZ extends Student {
//重寫父類Student的testScore()方法
@Override
public double testScore() {
return sum()/3+5;
}
public StudentBZ() {}
//StudentXW的構造函數(shù)
public StudentBZ(String studentNo,String studentName,double englishSocre,double computerScore,double mathScore) {
super(studentNo,studentName,englishSocre,computerScore,mathScore);
}
}
//測試類
public class Test {
public static void main(String[] args) {
//生成若干個student類、StudentXW類、StudentBZ類
Student student1 = new Student("s001","張三",70.5,50,88.5);
Student student2 = new Student("s002","李四",88,65,88.5);
Student student3 = new Student("s003","王五",67,77,90);
StudentXW student4 = new StudentXW("s004","李六",99,88,99.5);
StudentBZ student5 = new StudentBZ("s005","朱漆",56,65.6,43.5);
Student[] students = {student1,student2,student3,student4,student5};
for(int i = 0 ; istudents.length; i++){
double avgScore = students[i].testScore();
System.out.println(students[i].getStudentName()+"學生的評測成績?yōu)椋?+ avgScore+"分");
}
}
}
運行結果為:
張三學生的評測成績?yōu)椋?9.66666666666667分
李四學生的評測成績?yōu)椋?0.5分
王五學生的評測成績?yōu)椋?8.0分
李六學生的評測成績?yōu)椋?8.5分
朱漆學生的評測成績?yōu)椋?0.03333333333333分