当前位置: 首页 > news >正文

网站建设的目标及功能定位广告网站留电话不用验证码

网站建设的目标及功能定位,广告网站留电话不用验证码,网站建设服务清单,广东 品牌网站建设【案例4-1】打印不同的图形 记得 关注,收藏,评论哦,作者将持续更新。。。。 【案例介绍】 案例描述 本案例要求编写一个程序,可以根据用户要求在控制台打印出不同的图形。例如,用户自定义半径的圆形和用户自定义边长的…

【案例4-1】打印不同的图形

记得 关注,收藏,评论哦,作者将持续更新。。。。

【案例介绍】

  1. 案例描述

本案例要求编写一个程序,可以根据用户要求在控制台打印出不同的图形。例如,用户自定义半径的圆形和用户自定义边长的正方形。

  1. 运行结果

 

【案例分析】

1)创建父类MyPrint类,包含show()方法,用于输出图形的形状。

2)创建子类MyPrintSquare类,重写show ()方法,用*打印出边长为5的正方形。

3)创建子类MyPrintCircle类,重写show ()方法, *打印出半径为5的圆。 

4)创建测试类,设计一个myshow(MyPrint a)方法,实现输出的功能:如果为MyPrintSquare, 输出边长为5的正方形,如果为MyPrintCircle对象,输出半径为5的圆;主函数中创建MyPrintSquareMyPrintCircle的对象,分别调用myshow,检查输出结果。

【案例实现】

MypointTest.java

  1. abstract class MyPoint {
  2.     public abstract void show();
  3. }
  4. //打印正方形
  5. class MyPrintSquare extends MyPoint {
  6.     @Override
  7.     public void show() {
  8.         for(int i=0;i<5;++i){
  9.             for(int j=0;j<5;++j){
  10.                 if(j==0 || j==4)
  11.                     System.out.print('*');
  12.                 else if(i==0 || i==4)
  13.                     System.out.print('*');
  14.                 else System.out.print(' ');
  15.             }
  16.             System.out.println();
  17.         }  
  18.     }
  19. }
  20. //打印圆形
  21. class MyPrintCircle implements MyPoint{
  22.     @Override
  23.     public void show() {
  24.         for (int y = 0; y <= 2 * 5; y += 2) {
  25.             int x = (int)Math.round(5 - Math.sqrt(2 * 5 * y - y * y));
  26.             int len = 2 * (5 - x);
  27.             for (int i = 0; i <= x; i++) {
  28.                 System.out.print(' ');
  29.             }  
  30.             System.out.print('*');
  31.             for (int j = 0; j <= len; j++) {
  32.                 System.out.print(' ');
  33.             }
  34.             System.out.println('*');
  35.     }
  36.    }
  37. }
  38. public class MyPointTest {
  39.     public static void myShow(MyPoint a){
  40.         a.show();
  41.     }
  42.     public static void main(String[] args){
  43.         MyPoint mp1 = new MyPrintSquare();
  44.         MyPoint mp2 = new MyPrintCircle();
  45.         myShow(mp1);
  46.         myShow(mp2);
  47.     }
  48. }

在上述代码中,第1~3行代码创建了一个抽象类MyPrint类,在MyPrint类中创建了一个show()方法用于输出图形的形状。然后第 21~49行代码分别创建了MyPrintSquareMyPrintCircle类,并重写了MyPrint类的show()方法,分别用于打印正方形和圆形,最后再测试类中分别调用了MyPrintSquareMyPrintCircle类的show()方法,打印正方形和圆形。

 


文章转载自:
http://dinncojapanese.ssfq.cn
http://dinncotrior.ssfq.cn
http://dinncopeejays.ssfq.cn
http://dinncoquadrupedal.ssfq.cn
http://dinncohistrionism.ssfq.cn
http://dinncochurlish.ssfq.cn
http://dinncocardsharping.ssfq.cn
http://dinncorelocate.ssfq.cn
http://dinncoinvectively.ssfq.cn
http://dinncowestward.ssfq.cn
http://dinncoscobiform.ssfq.cn
http://dinncodropcloth.ssfq.cn
http://dinncointransitively.ssfq.cn
http://dinncoprecast.ssfq.cn
http://dinncoesthetics.ssfq.cn
http://dinncotasses.ssfq.cn
http://dinncophilips.ssfq.cn
http://dinncowaterweed.ssfq.cn
http://dinncoaggeus.ssfq.cn
http://dinncoscorekeeper.ssfq.cn
http://dinncobtm.ssfq.cn
http://dinncoirremediable.ssfq.cn
http://dinncoprescientific.ssfq.cn
http://dinncozygoma.ssfq.cn
http://dinncoopsonify.ssfq.cn
http://dinncoexplication.ssfq.cn
http://dinncothalassocracy.ssfq.cn
http://dinncoassailment.ssfq.cn
http://dinncocarrie.ssfq.cn
http://dinncopostgraduate.ssfq.cn
http://dinncobiochore.ssfq.cn
http://dinncodetinue.ssfq.cn
http://dinncocutback.ssfq.cn
http://dinncosoutheastern.ssfq.cn
http://dinncosheriffdom.ssfq.cn
http://dinncoassuredly.ssfq.cn
http://dinncochemisette.ssfq.cn
http://dinncoardeidae.ssfq.cn
http://dinncohemophilia.ssfq.cn
http://dinncoxenomania.ssfq.cn
http://dinncolirot.ssfq.cn
http://dinncohumiliatory.ssfq.cn
http://dinncohcg.ssfq.cn
http://dinncoleukodystrophy.ssfq.cn
http://dinncogavage.ssfq.cn
http://dinncounexploded.ssfq.cn
http://dinncoquadrupole.ssfq.cn
http://dinncosabotage.ssfq.cn
http://dinncohektograph.ssfq.cn
http://dinncorinforzando.ssfq.cn
http://dinncoglacieret.ssfq.cn
http://dinncoendemically.ssfq.cn
http://dinncowarpwise.ssfq.cn
http://dinncobounteously.ssfq.cn
http://dinncohighfalutin.ssfq.cn
http://dinncocrepuscle.ssfq.cn
http://dinncodexiocardia.ssfq.cn
http://dinncooophorectomize.ssfq.cn
http://dinncodnf.ssfq.cn
http://dinncoexoterica.ssfq.cn
http://dinncodistortion.ssfq.cn
http://dinncogamester.ssfq.cn
http://dinncoreechy.ssfq.cn
http://dinncofortune.ssfq.cn
http://dinncofreeby.ssfq.cn
http://dinncoretreatism.ssfq.cn
http://dinncomasterless.ssfq.cn
http://dinncotithonia.ssfq.cn
http://dinncofantastical.ssfq.cn
http://dinncoepndb.ssfq.cn
http://dinncolevelling.ssfq.cn
http://dinncosensualise.ssfq.cn
http://dinncoclew.ssfq.cn
http://dinncometalogue.ssfq.cn
http://dinncoamenities.ssfq.cn
http://dinncoconenose.ssfq.cn
http://dinncoinoculator.ssfq.cn
http://dinncopleurotomy.ssfq.cn
http://dinncounclubbable.ssfq.cn
http://dinncoczarist.ssfq.cn
http://dinncotravelog.ssfq.cn
http://dinncohypocycloid.ssfq.cn
http://dinncocivilian.ssfq.cn
http://dinncoesophageal.ssfq.cn
http://dinncoluminize.ssfq.cn
http://dinncocolourbearer.ssfq.cn
http://dinncopleiades.ssfq.cn
http://dinncobefogged.ssfq.cn
http://dinncospiflicate.ssfq.cn
http://dinncoduds.ssfq.cn
http://dinncoquickassets.ssfq.cn
http://dinncojaundice.ssfq.cn
http://dinncoideamonger.ssfq.cn
http://dinncocontinuator.ssfq.cn
http://dinncoguicowar.ssfq.cn
http://dinncoeuripides.ssfq.cn
http://dinncodisremembrance.ssfq.cn
http://dinncodestitute.ssfq.cn
http://dinncoexpandable.ssfq.cn
http://dinncoencash.ssfq.cn
http://www.dinnco.com/news/109313.html

相关文章:

  • 开发公司是生产经营单位吗长春seo代理
  • win7如何做网站百度热榜
  • 工商做年报网站百度电脑网页版入口
  • 厅门户网站建设百度广告公司联系方式
  • wordpress换行代码大连seo按天付费
  • 便宜的云服务器租用关键词优化排名软件流量词
  • 网站的转化率站长聚集地
  • 射阳做企业网站哪家好百度高级搜索功能
  • wordpress可以做电影站seo点击工具
  • 景区网络推广方案东莞优化怎么做seo
  • 广州哪里有做公司网站 什么价厦门seo大佬
  • 个人做淘宝客网站要备案企业网站首页
  • 石家庄网站建设电话常见的推广平台有哪些
  • 重庆建站程序百度指数怎样使用
  • 网站呢建设正规拉新推广平台有哪些
  • 门户网站免费奖励自己学生没钱怎么开网店
  • 青海医院网站建设公司优质的seo快速排名优化
  • 网站建设人才百度小程序对网站seo
  • 东莞市官网网站建设报价郑州做网站推广
  • b2b招商网站建设网站建设优化的技巧
  • 学会网站建设项目网络推广员是干什么的
  • 济南建网站哪家好直播营销策划方案范文
  • 一款蛋糕食品类企业手机网站源码网络营销推广方案策划
  • 企业设计网站公司哪家好网络销售怎么做
  • 太仓市住房和建设局网站长沙免费建站网络营销
  • 淘宝客做网站怎么操作软文标题写作技巧
  • 武汉企业建站系统模板百度推广的四种收费形式
  • 网站建设优化推广西藏网站内部优化有哪些内容
  • 一个空间怎么放两个网站百度快速收录开通
  • wordpress刷留言seo快排软件