学习对象编程--游戏玛利亚的位置
package com.assignmet;
import java.util.Scanner;
public class Tady11 {
public static void main(String[] args) {
// TODO Auto-generated method stub\
Scanner sr1=new Scanner(System.in);
Scanner sr2=new Scanner(System.in);
Maliya ml=new Maliya();
System.out.println("请输入玛利亚的坐标位置:");
System.out.print("纵坐标:");ml.x=sr1.nextInt();
//System.out.println();
System.out.print("横坐标:");ml.y=sr2.nextInt();
System.out.println();
if(ml.x!=1&&ml.x!=25&&ml.x<25&&ml.x>0&&ml.y!=8&&ml.y!=1&&ml.y>0&&ml.y<8)
{
ml.moer();
} else {System.out.println("您的输入不对超出活动范围,退出游戏");
}
}
}
class Maliya
{
int x;
int y;
public Maliya()
{
System.out.println(" l`m is Maliya "+"“@”");
for(int h=1;h<=25;h++)
{
System.out.print("=");
}
System.out.println();
}
public void moer()
{
for (int b=1;b<=8;b++)
{
for (int a=1;a<=25;a++)
{
if (a==1&&b==1)
{
System.out.print("╔");
}
else if(a==25&&b==1)
{
System.out.print("╗");
}else if(a==1&&b==2||a==25&&b==2)
{
System.out.print("║");
}else if(a==1&&b==3||a==25&&b==3)
{
System.out.print("║");
}else if(a==1&&b==4||a==25&&b==4)
{
System.out.print("║");
}
else if(a==1&&b==5||a==25&&b==5)
{
System.out.print("║");
}else if(a==1&&b==6||a==25&&b==6)
{
System.out.print("║");
}else if(a==1&&b==7||a==25&&b==7)
{
System.out.print("║");
}else if(a==1&&b==8)
{
System.out.print("╚");
}else if(a==25&&b==8)
{
System.out.print("╝");
}else if (a!=1&&b==1)
{
System.out.print("═");
}else if (a!=1&&b==8)
{
System.out.print("═");
} else if(a==x&&b==y)
{
System.out.print("@");
}
else
{
System.out.print(" ");
}
}System.out.println();
}
}
}