Topic: 这样算是面向对象么? |
Print this page |
1.这样算是面向对象么? | Copy to clipboard |
Posted by: fdiskfix Posted on: 2006-03-15 23:20 刚刚学习JAVA,写了一个很不健全的"回心数"程序,请勿耻笑!由于刚刚学习,所以只能判断3-5位的,(3位才开始有的回心数吧?)而且还没学怎么输入,只能靠方法调用!小弟以前学的都是“面向过程的语言”先不说算法的好坏,只想知道我这个程序有没有“面向对象”的思想在里面?有或没有是从哪里体现的呢?多谢各位点评了! 代码如下! class dooperation { public void opinion(int number) { if(number>99&&number<=99999) { if((number>99)&&(number<999)) contrast(number); else if((number>999)&&(number<9999)) contrast1(number); else if(number>9999) contrast2(number); } else System.out.println("You Write Number Is Error"); System.out.println("Only 100-99999"); } //contrast方法是用来按位比较的! private void contrast(int number) { if((number/100)==(number%10)) println(1); else println(0); } private void contrast1(int number) { if(((number/1000)==(number%10))&&((number/100%10)==(number/10%10))) println(1); else println(0); } private void contrast2(int number) { if(((number/10000)==(number%10))&&((number/1000%10)==(number/10%10))) println(1); else println(0); } private void println(int n) { if (n==1) System.out.println("YES"); else System.out.println("NO"); } } class exercise1 { public static void main (String []args) { dooperation p=new dooperation(); p.opinion(3) // 假设输入的是3 } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |