2. 把今天视频中的装大象案例的伪代码,转换成可以运行的java代码,并以此了解面向对象的思想
*/
class HomeWorkDemo
{
public static void main(String[]args)
{
Demo d=new Demo();
int a=d.sum(3,5);
System.out.println(a);
d.xiangtong(2,3);
d.print();
}
}
class Demo
{
public static int sum(int a,int b)
{
return a+b;
}
public static void xiangtong(int a,int b)
{
if (a==b)
{
System.out.println("这两个数是相同的");
}else
{
System.out.println("这两个数是不相同的");
}
}
public static void print()
{
for (int i=1;i<=9 ;i++ )
{
for (int j=1;j<=i ;j++ )
{
System.out.print(j+"*"+i+"="+j*i+"\t");