
已解决问题
谷歌summer灬辉辉用户在2014.05.04提交了关于“村上春树j**a的源代码”的提问,欢迎大家涌跃发表自己的观点。目前共有7个回答,最后更新于2024-12-13T12:04:44。希望大家能够帮助她。详细问题描述及疑问:期待您的答案,我不知道说什么才好,除了谢谢 !
详细问题描述及疑问:期待您的答案,我不知道说什么才好,除了谢谢 !
importj**ax.sw
importj**a.awt.*;
importj**a.awt.event.*;
publicclasslianliankanimple
{
JFramem
ContainerthisContainer;
JPanelcenterP
JButtondiam
JButto
JLab
JButtonfirstButton,secondButton;//分别记录两次被选中的按钮
intgrid[][]=n
staticbooleanpressInformat
intx0=0,y0
inti,j,
publicvoidinit(){
mainFrame=new
thisContainer=mai
thisContainer.s
cen
southPanel=n
northPanel=newJPanel();
thi
thi
thisContainer.add(northPan
centerPanel.setL
for(intcol
for(introws=0;rows<5;rows++){
diamondsButto
di
centerPanel
}
}
exitButton=newJButton
exitButton.addActionListener(this);
resetButton=newJButton("重列");
re
newlyButton=newJButton("再来一局")
newlyButton.addActionListener(this);
so
sou
southPanel.add(newl
fractionLabl
northPanel.a
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
publicvoidrandomBuild(){
intrandoms,cols,rows;
for(inttwins=1;twins<=15;twins++){
randoms=(int)(Math.random()*25+1);
for(intalike=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;
}
}
}
publicvoidfraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));
}
publicvoidreload(){
ints**e[]=newint[30];
intn=0,cols,rows;
intgrid[][]=newint[8][7];
for(inti=0;i<=6;i++){
for(intj=0;j<=5;j++){
if(this.grid[i][j]!=0){
s**e[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]=s**e[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false;//这里一定要将按钮点击信息归为初始
init();
for(inti=0;i<6;i++){
for(intj=0;j<5;j++){
if(grid[i+1][j+1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
publicvoidestimateEven(intplaceX,intplaceY,JButtonbz){
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();
}
}
}
publicvoidxiao(){//相同的情况下能不能消去。仔细分析,不一条条注释
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;
bre**;
}
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;
bre**;
}
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;
bre**;
}
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;
bre**;
}
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;
bre**;
}
else{k=1;}
}
if(k==1){
rowPassOne();
}
}
if(x<i){
for(j=x+1;j<=i;j++){
if(grid[j][y]!=0){
k=0;
bre**;
}
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;
bre**;
}
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;
bre**;
}
if(grid[i][n]==0&&n==y+1){
remove();
}
}
}
}
}
}
}
publicvoidlinePassOne(){
if(y0>j){//第一按钮同行空按钮在左边
for(i=y0-1;i>=j;i--){//判断第一按钮同左侧空按钮之间有没按钮
if(grid[x0][i]!=0){
k=0;
bre**;
}
else{k=2;}//K=2说明通过了第二次验
}
}
if(y0<j){//第一按钮同行空按钮在与第二按钮之间
for(i=y0+1;i<=j;i++){
if(grid[x0][i]!=0){
k=0;
bre**;
}
else{k=2;}
}
}
}
publicvoidrowPassOne(){
if(x0>i){
for(j=x0-1;j>=i;j--){
if(grid[j][y0]!=0){
k=0;
bre**;
}
else{k=2;}
}
}
if(x0<i){
for(j=x0+1;j<=i;j++){
if(grid[j][y0]!=0){
k=0;
bre**;
}
else{k=2;}
}
}
}
publicvoidremove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
publicvoidactionPerformed(ActionEvente){
if(e.getSource()==newlyButton){
intgrid[][]=newint[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(intcols=0;cols<6;cols++){
for(introws=0;rows<5;rows++){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);
}
}
}
publicstaticvoidmain(String[]args){
lianliankanllk=newlianliankan();
llk.randomBuild();
llk.init();
}
}
你去j**a网站下载jdk就行本身就是开源的可以直接查看的
j**a的源代码,一般在jdk安装的时候就安装到了jdk目录下的src目录中了
是不是openjdk??
s什么源码?
J**a的源代码?
问的是JDK源代码?
还是说J**a写的小程序源码?请提问者描述清楚
自己的应用还是jdk的源代码?