结对编程 第二阶段报告

一、实验目标
  1)体验敏捷开发中的两人合作。

  2)进一步提高个人编程技巧与实践。

二 、实验内容
  1)根据以下问题描述,练习结对编程(pair programming)实践;

  2)要求学生两人一组,自由组合。每组使用一台计算机,二人共同编码,完成实验要求。

  3)要求在结对编程工作期间,两人的角色至少切换 4 次;

  4)编程语言不限,版本不限。建议使用 Python 或 JAVA 进行编程。

1.实验代码规范

(1)命名规范:

类名是一个名词,采用大小写混合的方式,每个单词的首字母大写。此次用的静态类也有词组,但是依然遵从首字母大写的原则,

例如:ArrowActionListener,SquareActionListener,WdActionListener

接口的大小写规则与类名相似:例如:ActionListener

变量名第一个字母小写,任何中间单词的首字母大写。变量名应简短且可以顾名思义,易于记忆。例如:int arrowsColumns,int arrowsRows,

int minimunColumns

(2)注释规范(此次结对编程最重要核心部分)

1)注释尽可能使用“//”;对于所有的javadoc的注释则使用“/** */”;而临时对代码块进行注释尽量使用“/* */”。

2)所有的源文件都应该在开头有一个注释,其中列出文件名、日期和类的功能概述。

3)每个方法必须添加文档注释(类的main()方法除外)。

4)每个属性必须添加注释。

5)代码中至少包含15%的注释。

6)注释使用中文。

(3)缩进排版规范

1)避免一行的长度超过60个字符。

2)使用Eclipse的源代码的格式化功能完成代码的缩进排版(Ctrl+Shift+F)。

(4)编程规范

1)提供对实例以及类变量的public或private访问控制,尽可能不适用默认值或protected访问控制。

2)避免用一个对象访问一个类的静态变量或方法。应该用类名代替。

3)避免在一个语句中给多个变量赋相同的值。

下面是我与季兴元同学按照代码规范写的代码部分:

2.程序的整体设计:

首先,设计程序时,最终目标就是让程序按照生命游戏的规则迭代。起始图形则自定义。

1.本程序主要分为两个大模块:界面实现和规则模拟

界面实现:

规则模拟:

3.程序结对编程过程(附图)及功能实现情况(附代码和图)

本次实验,季兴元同学在编写代码中负责界面实现,我负责具体规则实现。

我在负责检查代码中负责检查界面模块,季兴元同学负责检查规则实现。

代码:

package GameOfLife;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class LifeGame extends JFrame{/*界面设计*/
    private final World world;
    public LifeGame(int rows,int columns)    /*创建线程,游戏开始*/
    {
        world=new World(rows, columns);
        new Thread(world).start();
        add(world);
    }

    public static void main(String[]args)
    {
        LifeGame frame=new LifeGame(40, 50);

        JMenuBar menu=new JMenuBar();
        frame.setJMenuBar(menu);

        JMenu options =new JMenu("选择图形");/*从自定义的图案中选择一个进行游戏*/
        menu.add(options);/*菜单主界面添加options*/

        JMenuItem arrow=options.add("Arrow");
        arrow.addActionListener(frame.new ArrowActionListener());/*自定义图案,放到options中*/
        JMenuItem square=options.add("Square");
        square.addActionListener(frame.new SquareActionListener());
        JMenuItem wd=options.add("wd");
        wd.addActionListener(frame.new wdActionListener());

        JMenu help=new JMenu("Help");
        menu.add(help);

        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(1007,859);
        frame.setTitle("生命游戏");
        frame.setVisible(true);
        frame.setVisible(true);
        frame.setResizable(false);/*界面设计的参数 从上到下依次为 将窗口设置为中央,
        添加关闭选项,设置窗口大小,标题  设置刷新时不闪烁 设置为不可自由调整大小 */
    }
    class ArrowActionListener implements ActionListener
    {                                                 /*arrow继承侦听器*/
        public void actionPerformed(ActionEvent e)
        {
            world.setArrow();
        }
    }
    class SquareActionListener implements ActionListener /*square继承侦听器*/
    {
        public void actionPerformed(ActionEvent e)
        {
            world.setSquare();
        }
    }
    class wdActionListener implements ActionListener /*wd继承侦听器*/
    {
        public void actionPerformed(ActionEvent e)
        {
            world.setwd();
        }
    }
}
package GameOfLife;

import java.awt.*;
import javax.swing.*;

public class World extends JPanel implements Runnable{/*此部分java方法用于遵守生命游戏的规则*/
    private final int rows;/*行*/
    private final int columns;
    private final CellStatus[][] generation1;/*用于迭代的几个数组*/
    private final CellStatus[][] generation2;
    private CellStatus[][] currentGeneration;
    private CellStatus[][] nextGeneration;
    private volatile boolean isChanging = false;

    public World(int rows, int columns)
    {
        this.rows=rows;
        this.columns=columns;
        generation1=new CellStatus[rows][columns];
        for(int i=0;i<rows;i++)
        {
            for(int j=0;j<columns;j++)
            {
                generation1[i][j]=CellStatus.Dead;/*首先,将所有的点定义成死亡点*/
            }
        }
        generation2=new CellStatus[rows][columns];
        for(int i=0;i<rows;i++)
        {
            for(int j=0;j<columns;j++)
            {
                generation2[i][j]=CellStatus.Dead;
            }
        }
        currentGeneration=generation1;
        nextGeneration=generation2;
    }

    public void run()
    {
        while(true)
        {
            synchronized(this)
            {
                while(isChanging)
                {
                    try
                    {
                        this.wait();
                    }catch(InterruptedException e)
                    {
                        e.printStackTrace();
                    }
                }
                repaint();
                sleep(1);/*定义睡眠时间*/
                for(int i=0;i<rows;i++)
                {
                    for(int j=0;j<columns;j++)
                    {
                        evolve(i,j);
                    }
                }
                CellStatus[][]temp=null;
                temp=currentGeneration;
                currentGeneration=nextGeneration;/*迭代结果*/
                nextGeneration=temp;
                for(int i=0;i<rows;i++)
                {
                    for(int j=0;j<columns;j++)
                    {
                        nextGeneration[i][j]=CellStatus.Dead;
                    }
                }
            }
        }
    }

    public void paintComponent(Graphics g)/*根据矩阵的值进行绘图*/
    {
        super.paintComponent(g);
        for(int i=0;i<rows;i++)
        {
            for(int j=0;j<columns;j++)
            {
                if(currentGeneration[i][j]==CellStatus.Active)
                {
                    g.fillRect(j*20, i*20, 20, 20);/*若迭代位置对应为 active则填充为黑色*/
                }
                else
                {
                    g.drawRect(j*20, i*20, 20, 20);/*死亡部分用矩形边框*/
                }
            }
        }
    }
    public void setArrow()
    {
        setShape(arrow);
    }
    public void setSquare()
    {
        setShape(square);
    }
    public void setwd()
    {
        setShape(wd);
    }
    private void setShape(int [][]shape)
    {
        isChanging=true;
        int arrowsRows=shape.length;
        int arrowsColumns=shape[0].length;
        int minimumRows=(arrowsRows<rows)?arrowsRows:rows;
        int minimunColumns=(arrowsColumns<columns)?arrowsColumns:columns;
        synchronized(this)
        {
            for(int i=0;i<rows;i++)
            {
                for(int j=0;j<columns;j++)
                {
                    currentGeneration[i][j]=CellStatus.Dead;
                }
            }
            for(int i=0;i<minimumRows;i++)
            {
                for(int j=0;j<minimunColumns;j++)
                {
                    if(shape[i][j]==1)
                    {
                        currentGeneration[i][j]=CellStatus.Active;
                    }
                }
            }
            isChanging=false;
            this.notifyAll();
        }
    }
    public void evolve(int x,int y)/*衍化的具体规则实现*/
    {
        int activeSurroundingCell=0;
        if(isVaildCell(x-1,y-1)&&(currentGeneration[x-1][y-1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x,y-1)&&(currentGeneration[x][y-1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x+1,y-1)&&(currentGeneration[x+1][y-1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x+1,y)&&(currentGeneration[x+1][y]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x+1,y+1)&&(currentGeneration[x+1][y+1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x,y+1)&&(currentGeneration[x][y+1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x-1,y+1)&&(currentGeneration[x-1][y+1]==CellStatus.Active))
            activeSurroundingCell++;
        if(isVaildCell(x-1,y)&&(currentGeneration[x-1][y]==CellStatus.Active))
            activeSurroundingCell++;
        //
        if(activeSurroundingCell==3)
        {
            nextGeneration[x][y]=CellStatus.Active;
        }
        else if(activeSurroundingCell==2)
        {
            nextGeneration[x][y]=currentGeneration[x][y];
        }
        else
        {
            nextGeneration[x][y]=CellStatus.Dead;
        }
    }
    private boolean isVaildCell(int x,int y)
    {
        if((x>=0)&&(x<rows)&&(y>=0)&&(y<columns))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    private void sleep(int x)
    {
        try {
            Thread.sleep(1000*x);
        } catch (InterruptedException e) {
                e.printStackTrace();
        }
    }
    static enum CellStatus
    {
        Active,
        Dead;
    }
     private static final int[][] arrow = {//40*50  自定义的图案
        {0,0,0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0,0,0,0,0,0,0,0}
    };

    private static final int[][] square = {
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    };
    private static final int[][] wd = {
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
            {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
        };
}

功能实现:

因为编写过程中bug较多,后期后期才想起截图,这里放几张图片

此处线程出现问题

项目git地址:https://github.com/paxifaer/pp_project.git

实验小结

本次实验受益良多,参考了很多网上的代码。因为Java的比如将矩阵转换成图形。在给定图形后如何进行新一轮的迭代

等等。

这次结对编程实验让我体会到不一样的编程。平常自己检查不到的错误对方却很容易检查的出来。fingbugs确实好用,但是

一些马虎造成的问题比如类名调用错误,还是需要个人来调试。

时间原因,此次结对编程并不算圆满。但是从中确实收获了不少。

原文地址:https://www.cnblogs.com/pxfa/p/12637833.html

时间: 2024-11-13 06:45:27

结对编程 第二阶段报告的相关文章

结对编程 第二阶段

一.实验目标 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 三.组队情况: 1.队名:WxWz 2.各队员博客地址:3170701103 王旭(https://www

实验二 结对编程 第二阶段

结对编程(阶段二) 一.实验目标1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 博客内容应该包括:1.代码规范 在编写代码时我们一般遵循代码规范的七大原则——空行.空格.

结对编程第二阶段

一.实验目标 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 三.实验过程 1)代码规范 (1)运用一个函数之前,需要对其进行定义. (2)代码格式尽量对其. (3)在

实验二 结对编程第二阶段

一.实验目标: 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容: 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 三 .实验过程记录 1)总体设计 2)  结对编程过程 刚开始我们只是简单的讨论了一下大概的模块设计.

软件工程 实验二 结对编程(第二阶段)

一.实验目标: 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容: 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)两个学生组合,每人使用一台计算机,二人共同编码,完成实验要求. 3)针对课题查阅相关资料,加深对课题的理解: 4)在结对编程工作期间,两人的角色至少切换 4 次: 5)实验过程中合作编程两人互相探讨后采用开发平台和技术,语言工具,准备实验开展工作: 6)做好试验记录和分析工作. 三.实验过程 (一)问题描述 生命游

实验二结对编程 第二阶段

实验目标 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 实验内容 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 1.代码规范 (1)空行与空格:空行起着分隔程序段落的作用,空行得体将使程序的布局更加清晰.每当定义变量和函数后都要

实验:结对编程 第二阶段

结对编程 一.实验目标: 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容: 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 三.问题描述 四则运算:开发一个自动生成小学四则运算题目的命令行 “软件”.实现 输入你要出

结对编程(第二阶段)

一.实验目标 1)体验敏捷开发中的两人合作. 2)进一步提高个人编程技巧与实践. 二 .实验内容 1)根据以下问题描述,练习结对编程(pair programming)实践: 2)要求学生两人一组,自由组合.每组使用一台计算机,二人共同编码,完成实验要求. 3)要求在结对编程工作期间,两人的角色至少切换 4 次: 4)编程语言不限,版本不限.建议使用 Python 或 JAVA 进行编程. 1.代码规范 (1)类名首字母应大写,字段.方法名以及对象的首字母小写,代码中的命名不允许使用中文,包名使

结对-结对编程项目作业名称-结对项目总结

结对编程项目进度报告 项目名称:电灯游戏 人    员:董馨遥  2015035107077 杨  露  2015035107084 所用时间:2017.09.14 ----2017.10.25 游戏项目分析:有个N行N列的正方形灯板,当你开关其中一盏灯:它和上下左右的灯的状态全部反转,如果被点击的灯不是第一排,则改变上边的灯,如果被点击的灯不是最后一排,则改变下边的灯,如果被点击的灯是最左边,则改变右边的灯,如果被点击的灯适最右边,则改变左边的灯.最后是所有的灯都亮 游戏运行结果:运行代码后,