1 / 2

1 调试程序,改正错误,使程序正常运行。 class M{ int a; public int b; private int c;

1 调试程序,改正错误,使程序正常运行。 class M{ int a; public int b; private int c; private void print(){ System.out.println(c); } } public class Test { public static void main(String args[]){ M m = new M(); m.a = 9; m.b=20; m.c = 99;

connor
Download Presentation

1 调试程序,改正错误,使程序正常运行。 class M{ int a; public int b; private int c;

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1 调试程序,改正错误,使程序正常运行。 class M{ int a; public int b; private int c; private void print(){ System.out.println(c); } } public class Test { public static void main(String args[]){ M m = new M(); m.a = 9; m.b=20; m.c = 99; System.out.println( m.a + m.b + m.c ); m.print(); }

  2. 1 建立一个日期类,表达年月日。 1)设置一个日期的方法,注意,年不能为负数,月要在1-12之间,日要在 1-31之间,否则不要赋值。如能考虑闰年、大月、小月更好。 2)返回年、月、日的方法, 3)可以计算是否是闰年,返回 True /false 4)打印如 2010-11-20 的日期 *5) 比较两个日期是否相等,相等返回 true. • 2 写出一个表示复数的类。 复数由实部及虚部组成,显示为(a , bi),a为实部,b为虚部。 要求:1)能为复数赋值 2)能打印如 (3+7i) 的复数 3)实现虚数的加运算。 4)实现虚数的减运算。 测试:计算(2,5i)及(3,7i)的和及差,并打印和、差。

More Related