zoukankan      html  css  js  c++  java
  • 第一章-第十四题(Hello world程序)

    题目:请找一个同学结对 (参看本书结对编程的内容),两人共同工作 (不能分开干活),从上面的列表中选取两个平台,在每个平台上,写一个最简单的 "Hello World" 类型的程序,把写程序的经历写成博客发布出来,内容包括:

    - 什么平台, 用什么编程语言,什么软件构建环境 (IDE),什么软件工程的工具,开发的流程大概是什么,最后程序的源码,和用户界面是什么?(可以从网上查找相关资料,甚至源程序都可以参考其他人的, 但是要自己把程序编译,运行)

     

    --平台

      windows 7

    --语言

      java

    --构建环境

      jdk1.8  、 SDK  

    --开发工具

       android studio 2.1

    --开发流程

      a)在Android Studio上创建Android project

      b)编写界面XML布局

      c)编写动画XML代码

      d)在Activity中初始化TetxtView,并给它设置动画

      d)打包签名,生成release版apk

      e)启动安卓模拟器,在模拟器上安卓apk并运行程序

    --源代码

      a)MainActivity.java源代码

    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Animation animation= AnimationUtils.loadAnimation(this,R.anim.animation);
            TextView tv=(TextView)findViewById(R.id.helloworld);
            tv.startAnimation(animation);
        }
    }

      b)activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    
        tools:context="com.example.administrator.myfirstapp.MainActivity">
    
        <TextView
            android:id="@+id/helloworld"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="35px"
            android:textColor="#f57a07"
            android:text="Hello World!" />
    </RelativeLayout>

      c)animation.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <rotate android:fromDegrees="0"
            android:toDegrees="+360"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="1000"/>
    
        <translate
            android:fromXDelta="0"
            android:toXDelta="100%"
            android:fromYDelta="0"
            android:toYDelta="100%"
            android:duration="5000"/>
    
        <scale
            android:fromXScale="0px"
            android:toXScale="250px"
            android:fromYScale="0px"
            android:toYScale="100px"/>
    </set>

    --界面

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    --平台

      windows 7

    --语言

      java

    --构建环境

      jdk1.7    

    --开发工具

       myeclipse 10

    --开发流程

      首先考虑到了题目中要求网页平台是只要有浏览器就可以访问软件或服务,所以我们讨论将其设计为servlet获取请求,完成要求的形式,以便于可以满足远程访问的要求。

      a)在myeclipse 上创建web project

      b)创建servlet,设置配置文件

      c)编写servlet中的函数,要求跳转到showHelloWorld.jsp

      d)在showHelloWorld.jsp中设计hello world的展示风格,设计的内容因为我们能力有限,所以就借鉴参考了网上资源。

      d)部署在tomcat服务器上,并运行服务

      e)启动浏览器,访问程序

     --源代码

    a)showHelloWorld.java

    public class showHelloWorld extends HttpServlet {
    
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        
        @Override
        protected void service(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            // TODO Auto-generated method stub
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset = utf-8");    
            
            request.getRequestDispatcher("showHelloWorld.jsp").forward(request, response);
    
        }
    }

    b)showHelloWorld.jsp

    <html>
    <head>
        <style>
            html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}
        </style>
    
        <style>
            body {
              background: #eee;
            }
            body .box {
              display: none;
            }
            body .render {
              width: 80%;
              display: block;
              margin: 50px auto;
            }
            body .render span {
              font-size: 70px;
              font-weight: 300;
            }
        </style>
        <script src="js/prefixfree.min.js"></script>
        <script src="js/modernizr.js"></script>
    </head>
    <body>
        <div class="box">
          <h1>Hello World !</h1>
          <h1>Hello World !</h1>
          <h1>Hello World !</h1>
        </div>
        <!-- render here -->
        <div class="render"></div>
          <script src="js/index.js"></script>
        <div style="text-align:center;clear:both">
        <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>
        <script src="/follow.js" type="text/javascript"></script>
        </div>  
      </body>
    <html>

    --运行界面

       

    其中,运行代码中helloworld的设计是参考了网络上关于文字特效的介绍,具体链接见参考资源。

    参考文献:

    1. http://www.html5tricks.com/css3-colorful-text-shadow.html

  • 相关阅读:
    关于:nth-children 的几点总结
    JQ常用知识点总结(笔记篇)————
    ajax的数据处理
    快捷小技巧
    javascript获取select,checkbox,radio的值
    面试题
    canvas基础
    python中的线程之semaphore信号量
    PHP中$_POST和$_GET的用法
    php中echo、print、print_r、var_dump、var_export区别
  • 原文地址:https://www.cnblogs.com/ghll/p/5858126.html
Copyright © 2011-2022 走看看