Programming Methodology(九)

这一节MEHRAN说要把之前的所有内容都串在一起,是最重要的一节课,还好是公开课不然一般这种课我都会错过...

 

1.      String: 和printline一样可以用+串联

2.      写一个自己的CLASS:不需要有run函数,而是需要有一个构造函数,构造函数的四个特点:

Name of the class is used as constructor name.

Constructor does not specify   return type.

Responsible for initializing objects.

It is called when object is created.

3.      当在函数中传递整数或者浮点数等传递的是副本,并不会改变值,如果参数是对象,则直接传递对象,会对对象造成改变.

4.      静态变量: private static counter

这个counter可以叫做类变量,所有的对象都指向这个类,如果将下面这个程序的private int counter变成类对象,那么结果会完全不同。

贴上上述三点的一个Counter程序:

package DefaultPackage;

import acm.program.*;

publicclass UseCounter extends ConsoleProgram {

    publicvoid run()

    {

       MyCounter count1 = new MyCounter(1000);

       MyCounter count2= new MyCounter();

      

       println("The nextfive number of count1: ");

       NextFiveNumber(count1);

      

       println("The nextfive number of count2: ");

       NextFiveNumber(count2);

      

       println("The nextfive number of count1: ");

       NextFiveNumber(count1);

    }

   

    publicclass MyCounter {

 

       public MyCounter(int StartNumber)

       {

           counter = StartNumber;

       }

       public MyCounter()

       {

           counter = 1;

       }

       publicint GiveNumber()

       {

           int temp = counter;

           counter++;

           return temp;

       }

       privateintcounter;

    }

   

    privatevoid NextFiveNumber(MyCounter mc)

    {

       for(int i = 0; i<5 ; i++)

       {

           println(mc.GiveNumber());

       }

    }

}

5. http://jtf.acm.org/javadoc/student/

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Extreme programming (XP) is a software development methodology that emphasizes teamwork, communication, simplicity, feedback, and customer satisfaction. Here are some key practices for XP: 1. Planning: Planning is an essential part of XP. The team plans the project in short iterations called "sprints" and they prioritize the tasks to be done in each sprint. 2. Pair programming: Pair programming is a technique in which two programmers work together on the same computer. One programmer writes the code and the other reviews it. This helps to catch errors and improve the quality of the code. 3. Continuous integration: Continuous integration is the practice of integrating code changes into the main codebase frequently. This helps to identify and fix integration issues early in the development cycle. 4. Test-driven development: Test-driven development (TDD) is a development technique in which tests are written before the code is written. This helps to ensure that the code is correct and meets the requirements. 5. Refactoring: Refactoring is the process of improving the design of the code without changing its functionality. This helps to keep the code maintainable and flexible. 6. Simple design: XP emphasizes keeping the design of the code simple and easy to understand. This helps to reduce complexity and improve maintainability. 7. Continuous feedback: XP emphasizes continuous feedback from the customer and the team. This helps to ensure that the project is on track and meets the customer's needs. These are just some of the key practices of XP. By following these practices, the team can improve the quality of the code, reduce the risk of errors, and deliver high-quality software that meets the customer's needs.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值