Fish to be a skilled programmer—second day

来源:互联网 发布:传奇3装备数据库 编辑:程序博客网 时间:2024/05/23 23:18

         Since graduated from university,life was barely fulfilling like this week. The excellent learning-habits  destroyed completely in the past years now were reconstructed little by little,  the consequent confidences give me plenty of power and courage. Nothing could stop you moving forward, so do not hesitate, do not look back, just fight! 


Summary of the first day :

1、what are software and program?

2、computer language:machine language>assembly language>high-level language.

3、the features of high-level language:compile and explain.

4、the steps of programming:analyse problem>determine the data structure and algorithm>programming>debugging problems.

5、algorithmic notations: pseudocode and flow diagram.

6、structure:sequence structure,select branch structure and cycle structure.

7、the common mistakes of coding: grammatical error,logic error,run-time error.

8、the origin and development of Java.

9、how to install jdk for pc.


/*
作者:刘建发
日期:2016.09.29
功能:this的必要性
*/


public class Demo8
{
     public static void main(String []args)
     {
     /*     Dog dog1=new Dog(2,"大黄");
          
          Person p1=new Person(dog1,23,"郭德纲"); 
          Person p2=new Person(dog1,24,"刘谦");
          p1.showInfo();
          p1.dog.showInfo();*/
   
          int total=0;


          Child ch1=new Child(3,"妞妞");
          ch1.joinGame();
         
          Child ch2=new Child(4,"小小");
          ch2.joinGame();


          Child ch3=new Child(5,"大大");
          ch3.joinGame();
          
          
          System.out.println("共有="+ch3.total);




     }
}


//定义小孩类
class Child
{
      int age;
      String name;
      //total是静态变量,因此他可以被任何一个对象访问
      static int total=0;
      public Child(int age,String name)
      {
           this.age=age;
           this.name=name;
           
       }
       
       public void joinGame()
       {
              total++;
              System.out.println("有一个小孩加入了");
        }
}










//定义一个人类
class Person
{
    //成员变量
    int age;
    String name;
    Dog dog;
    public Person(Dog dog,int age,String name)
    {
         //可读性不好
         this.dog=dog;
         this.age=age;
         this.name=name;
    }


    //显示人名字
    public void showInfo()
    {
         System.out.println("人名是:"+name);
    }
}


class Dog
{
     int age;
     String name;
     public Dog(int age,String name)
     {
           this.age=age;
           this.name=name;
     }
     //显示狗名
     public void showInfo()
     {
          System.out.println("狗名叫"+this.name);
     }
}

0 0
原创粉丝点击