WeixiangYan/CodeTransOcean huggingface dataset:
Task: Abstract type







Python: class BaseQueue(object):
    
    def __init__(self):
        self.contents = list()
        raise NotImplementedError
    def Enqueue(self, item):
        raise NotImplementedError
    def Dequeue(self):
        raise NotImplementedError
    def Print_Contents(self):
        for i in self.contents:
            print i,




Fortran:  
   
   type, abstract :: TFigure
      real(rdp) :: area
   contains
      
      procedure(calculate_area), deferred, pass :: calculate_area
   end type TFigure
   
   abstract interface
      function  calculate_area(this)
         import TFigure 
         implicit none
         class(TFigure) :: this
         real(rdp) :: calculate_area
      end function calculate_area
   end interface
Task: Abstract type






PHP: abstract class Abs {
	abstract public function method1($value);
	abstract protected function method2($name);
	function add($a, $b){
		return a + b;
	}
}





Fortran:  
   
   type, abstract :: TFigure
      real(rdp) :: area
   contains
      
      procedure(calculate_area), deferred, pass :: calculate_area
   end type TFigure
   
   abstract interface
      function  calculate_area(this)
         import TFigure 
         implicit none
         class(TFigure) :: this
         real(rdp) :: calculate_area
      end function calculate_area
   end interface
Task: Abstract type

C: #ifndef INTERFACE_ABS
#define INTERFACE_ABS

typedef struct sAbstractCls *AbsCls;

typedef struct sAbstractMethods {
    int         (*method1)(AbsCls c, int a);
    const char *(*method2)(AbsCls c, int b);
    void        (*method3)(AbsCls c, double d);
} *AbstractMethods, sAbsMethods;

struct sAbstractCls {
    AbstractMethods  klass;
    void     *instData;
};

#define ABSTRACT_METHODS( cName, m1, m2, m3 ) \
    static sAbsMethods cName ## _Iface = { &m1, &m2, &m3 }; \
    AbsCls cName ## _Instance( void *clInst) { \
        AbsCls ac = malloc(sizeof(struct sAbstractCls)); \
        if (ac) { \
            ac->klass = &cName ## _Iface; \
            ac->instData = clInst; \
        }\
        return ac; }

#define Abs_Method1( c, a) (c)->klass->method1(c, a)
#define Abs_Method2( c, b) (c)->klass->method2(c, b)
#define Abs_Method3( c, d) (c)->klass->method3(c, d)
#define Abs_Free(c) \
  do { if (c) { free((c)->instData); free(c); } } while(0);
 
#endif









COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type



C#: abstract class Class1
{
   public abstract void method1();

   public int method2()
   {
      return 0;
   }
}







COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type


C++: class Abs {
public:
	virtual int method1(double value) = 0;
	virtual int add(int a, int b){
		return a+b;
	}
};








COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type





Java: public abstract class Abs {
    public abstract int method1(double value);
    protected abstract int method2(String name);
    int add(int a, int b) {
        return a + b;
    }
}





COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type







Python: class BaseQueue(object):
    
    def __init__(self):
        self.contents = list()
        raise NotImplementedError
    def Enqueue(self, item):
        raise NotImplementedError
    def Dequeue(self):
        raise NotImplementedError
    def Print_Contents(self):
        for i in self.contents:
            print i,



COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type








VB: MustInherit Class Base

   Protected Sub New()

   End Sub

   Public Sub StandardMethod()
       
   End Sub

   Public Overridable Sub Method_Can_Be_Replaced()
       
   End Sub

   Public MustOverride Sub Method_Must_Be_Replaced()

End Class


COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type




Go: package main

import "fmt"

type Beast interface {
    Kind() string
    Name() string
    Cry() string
}

type Dog struct {
    kind string
    name string
}

func (d Dog) Kind() string { return d.kind }

func (d Dog) Name() string { return d.name }

func (d Dog) Cry() string { return "Woof" }

type Cat struct {
    kind string
    name string
}

func (c Cat) Kind() string { return c.kind }

func (c Cat) Name() string { return c.name }

func (c Cat) Cry() string { return "Meow" }

func bprint(b Beast) {
    fmt.Printf("%s, who's a %s, cries: %q.\n", b.Name(), b.Kind(), b.Cry())
}

func main() {
    d := Dog{"labrador", "Max"}
    c := Cat{"siamese", "Sammy"}
    bprint(d)
    bprint(c)
}






COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Abstract type






PHP: abstract class Abs {
	abstract public function method1($value);
	abstract protected function method2($name);
	function add($a, $b){
		return a + b;
	}
}
Task: Abstract type






PHP: abstract class Abs {
	abstract public function method1($value);
	abstract protected function method2($name);
	function add($a, $b){
		return a + b;
	}
}






Ada: type Queue is limited interface;
procedure Enqueue (Lounge : in out Queue; Item : in out Element) is abstract;
procedure Dequeue (Lounge : in out Queue; Item : in out Element) is abstract;
Task: Abstract type






PHP: abstract class Abs {
	abstract public function method1($value);
	abstract protected function method2($name);
	function add($a, $b){
		return a + b;
	}
}




COBOL:        INTERFACE-ID. Shape.
       
       PROCEDURE DIVISION.
       
       METHOD-ID. perimeter.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD perimeter.
       
       METHOD-ID. shape-area.
       DATA DIVISION.
       LINKAGE SECTION.
       01  ret USAGE FLOAT-LONG.
       PROCEDURE DIVISION RETURNING ret.
       END METHOD shape-area.
       
       END INTERFACE Shape.
       

       CLASS-ID. Rectangle. 
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           INTERFACE Shape.
       
       OBJECT IMPLEMENTS Shape.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01  width  USAGE FLOAT-LONG PROPERTY.
           01  height USAGE FLOAT-LONG PROPERTY.
           
           PROCEDURE DIVISION.
           
           METHOD-ID. perimeter.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * 2.0 + height * 2.0
               GOBACK
               .
           END METHOD perimeter.
       
           METHOD-ID. shape-area.
           DATA DIVISION.
           LINKAGE SECTION.
           01  ret USAGE FLOAT-LONG.
           PROCEDURE DIVISION RETURNING ret.
               COMPUTE ret = width * height
               GOBACK
               .
           END METHOD shape-area.
       END OBJECT.
       
       END CLASS Rectangle.
Task: Conway's Game of Life

C: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define for_x for (int x = 0; x < w; x++)
#define for_y for (int y = 0; y < h; y++)
#define for_xy for_x for_y
void show(void *u, int w, int h)
{
	int (*univ)[w] = u;
	printf("\033[H");
	for_y {
		for_x printf(univ[y][x] ? "\033[07m  \033[m" : "  ");
		printf("\033[E");
	}
	fflush(stdout);
}

void evolve(void *u, int w, int h)
{
	unsigned (*univ)[w] = u;
	unsigned new[h][w];

	for_y for_x {
		int n = 0;
		for (int y1 = y - 1; y1 <= y + 1; y1++)
			for (int x1 = x - 1; x1 <= x + 1; x1++)
				if (univ[(y1 + h) % h][(x1 + w) % w])
					n++;

		if (univ[y][x]) n--;
		new[y][x] = (n == 3 || (n == 2 && univ[y][x]));
	}
	for_y for_x univ[y][x] = new[y][x];
}

void game(int w, int h)
{
	unsigned univ[h][w];
	for_xy univ[y][x] = rand() < RAND_MAX / 10 ? 1 : 0;
	while (1) {
		show(univ, w, h);
		evolve(univ, w, h);
		usleep(200000);
	}
}

int main(int c, char **v)
{
	int w = 0, h = 0;
	if (c > 1) w = atoi(v[1]);
	if (c > 2) h = atoi(v[2]);
	if (w <= 0) w = 30;
	if (h <= 0) h = 30;
	game(w, h);
}











Ada: WITH Ada.Text_IO;  USE Ada.Text_IO;
 
PROCEDURE Life IS
   SUBTYPE Cell IS Natural RANGE 0 .. 1;

   TYPE Petri_Dish IS ARRAY (Positive RANGE <>, Positive RANGE <>) OF Cell;

   PROCEDURE Step (Gen : IN OUT Petri_Dish) IS
      Above       : ARRAY (Gen'Range (2)) OF Cell := (OTHERS => 0);
      Left, This  : Cell;
   BEGIN
      FOR I IN Gen'First (1) + 1 .. Gen'Last (1) - 1 LOOP
         Left := 0;
         FOR J IN Gen'First (2) + 1 .. Gen'Last (2) - 1 LOOP
            This := (CASE Above (J - 1) + Above (J) + Above (J + 1) +
                          Left			    + Gen (I, J + 1) +
                          Gen (I + 1, J - 1) + Gen (I + 1, J) 	+ Gen (I + 1, J + 1) IS
                        WHEN 2      => Gen (I, J),
                        WHEN 3      => 1,
                        WHEN OTHERS => 0);
            Above (J - 1):= Left;
            Left         := Gen (I, J);
            Gen (I, J) 	 := This;
         END LOOP;
         Above (Above'Last - 1) := Left;
      END LOOP;
   END Step;
 
   PROCEDURE Put (Gen : Petri_Dish) IS
   BEGIN
      FOR I IN Gen'Range (1) LOOP
         FOR J IN Gen'Range (2) LOOP
            Put ( if Gen (I, J) = 0 then " " else "#");
         END LOOP;
         New_Line;
      END LOOP;
   END Put;
 
   Blinker : Petri_Dish := (2 .. 4 => (0, 0, 1, 0, 0), 1 | 5 => (0, 0, 0, 0, 0));
   Glider  : Petri_Dish (1..6,1..11):= (2 => (3 => 1, others => 0),
                                        3 => (4 => 1, others => 0),
                                        4 => (2|3|4=>1, others => 0),
                                        others => (others => 0));
   PROCEDURE Put_And_Step_Generation (N : Positive; Name : String; P : IN OUT Petri_Dish) IS
   BEGIN
      FOR Generation IN 1 .. N LOOP
         Put_Line (Name & Generation'Img);
         Put (P);
         Step (P);
      END LOOP;
   END Put_And_Step_Generation;

BEGIN
   Put_And_Step_Generation (3, "Blinker", Blinker);
   Put_And_Step_Generation (5, "Glider", Glider);
END Life;
Task: Conway's Game of Life

C: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define for_x for (int x = 0; x < w; x++)
#define for_y for (int y = 0; y < h; y++)
#define for_xy for_x for_y
void show(void *u, int w, int h)
{
	int (*univ)[w] = u;
	printf("\033[H");
	for_y {
		for_x printf(univ[y][x] ? "\033[07m  \033[m" : "  ");
		printf("\033[E");
	}
	fflush(stdout);
}

void evolve(void *u, int w, int h)
{
	unsigned (*univ)[w] = u;
	unsigned new[h][w];

	for_y for_x {
		int n = 0;
		for (int y1 = y - 1; y1 <= y + 1; y1++)
			for (int x1 = x - 1; x1 <= x + 1; x1++)
				if (univ[(y1 + h) % h][(x1 + w) % w])
					n++;

		if (univ[y][x]) n--;
		new[y][x] = (n == 3 || (n == 2 && univ[y][x]));
	}
	for_y for_x univ[y][x] = new[y][x];
}

void game(int w, int h)
{
	unsigned univ[h][w];
	for_xy univ[y][x] = rand() < RAND_MAX / 10 ? 1 : 0;
	while (1) {
		show(univ, w, h);
		evolve(univ, w, h);
		usleep(200000);
	}
}

int main(int c, char **v)
{
	int w = 0, h = 0;
	if (c > 1) w = atoi(v[1]);
	if (c > 2) h = atoi(v[2]);
	if (w <= 0) w = 30;
	if (h <= 0) h = 30;
	game(w, h);
}
Task: Conway's Game of Life





Java: public class GameOfLife{
	public static void main(String[] args){
		String[] dish= {
				"_#_",
				"_#_",
				"_#_",};
		int gens= 3;
		for(int i= 0;i < gens;i++){
			System.out.println("Generation " + i + ":");
			print(dish);
			dish= life(dish);
		}
	}

	public static String[] life(String[] dish){
		String[] newGen= new String[dish.length];
		for(int row= 0;row < dish.length;row++){
			newGen[row]= "";
			for(int i= 0;i < dish[row].length();i++){
				String above= "";
				String same= "";
				String below= "";
				if(i == 0){
					
					
					above= (row == 0) ? null : dish[row - 1].substring(i,
									i + 2);
					same= dish[row].substring(i + 1, i + 2);
					
					
					below= (row == dish.length - 1) ? null : dish[row + 1]
									.substring(i, i + 2);
				}else if(i == dish[row].length() - 1){
					
					
					above= (row == 0) ? null : dish[row - 1].substring(i - 1,
									i + 1);
					same= dish[row].substring(i - 1, i);
					
					
					below= (row == dish.length - 1) ? null : dish[row + 1]
									.substring(i - 1, i + 1);
				}else{
					
					
					above= (row == 0) ? null : dish[row - 1].substring(i - 1,
									i + 2);
					same= dish[row].substring(i - 1, i)
									+ dish[row].substring(i + 1, i + 2);
					
					
					below= (row == dish.length - 1) ? null : dish[row + 1]
									.substring(i - 1, i + 2);
				}
				int neighbors= getNeighbors(above, same, below);
				if(neighbors < 2 || neighbors > 3){
					newGen[row]+= "_";
				}else if(neighbors == 3){
					newGen[row]+= "#";
				}else{
					newGen[row]+= dish[row].charAt(i);
				}
			}
		}
		return newGen;
	}

	public static int getNeighbors(String above, String same, String below){
		int ans= 0;
		if(above != null){
			for(char x: above.toCharArray()){
				if(x == '#') ans++;
			}
		}
		for(char x: same.toCharArray()){
			if(x == '#') ans++;
		}
		if(below != null){
			for(char x: below.toCharArray()){
				if(x == '#') ans++;
			}
		}
		return ans;
	}

	public static void print(String[] dish){
		for(String s: dish){
			System.out.println(s);
		}
	}
}