WeixiangYan/CodeTransOcean huggingface dataset:
Task: Symmetric difference



C#: using System;
using System.Collections.Generic;
using System.Linq;

namespace RosettaCode.SymmetricDifference
{
    public static class IEnumerableExtension
    {
        public static IEnumerable<T> SymmetricDifference<T>(this IEnumerable<T> @this, IEnumerable<T> that)
        {
            return @this.Except(that).Concat(that.Except(@this));
        }
    }

    class Program
    {
        static void Main()
        {
            var a = new[] { "John", "Bob", "Mary", "Serena" };
            var b = new[] { "Jim", "Mary", "John", "Bob" };

            foreach (var element in a.SymmetricDifference(b))
            {
                Console.WriteLine(element);
            }
        }
    }
}








Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference


C++: #include <iostream>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>

using namespace std;
 
int main( ) {
   string setA[] = { "John", "Bob" , "Mary", "Serena" };
   string setB[] = { "Jim" , "Mary", "John", "Bob"  };
   set<string> 
       firstSet( setA , setA + 4 ),
       secondSet( setB , setB + 4 ),
       symdiff;

   set_symmetric_difference( firstSet.begin(), firstSet.end(),
                             secondSet.begin(), secondSet.end(),
                             inserter( symdiff, symdiff.end() ) );

   copy( symdiff.begin(), symdiff.end(), ostream_iterator<string>( cout , " " ) );
   cout << endl;
   return 0;
}









Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference

C: #include <stdio.h>
#include <string.h>

const char *A[] = { "John", "Serena", "Bob", "Mary", "Serena" };
const char *B[] = { "Jim", "Mary", "John", "Jim", "Bob" };

#define LEN(x) sizeof(x)/sizeof(x[0])


void uniq(const char *x[], int len)
{
	int i, j;
	for (i = 0; i < len; i++)
		for (j = i + 1; j < len; j++)
			if (x[j] && x[i] && !strcmp(x[i], x[j])) x[j] = 0;
}

int in_set(const char *const x[], int len, const char *match)
{
	int i;
	for (i = 0; i < len; i++)
		if (x[i] && !strcmp(x[i], match))
			return 1;
	return 0;
}


void show_diff(const char *const x[], int lenx, const char *const y[], int leny)
{
	int i;
	for (i = 0; i < lenx; i++)
		if (x[i] && !in_set(y, leny, x[i]))
			printf("  %s\n", x[i]);
}


void show_sym_diff(const char *const x[], int lenx, const char *const y[], int leny)
{
	show_diff(x, lenx, y, leny);
	show_diff(y, leny, x, lenx);
}

int main()
{
	uniq(A, LEN(A));
	uniq(B, LEN(B));
	printf("A \\ B:\n"); show_diff(A, LEN(A), B, LEN(B));
	printf("\nB \\ A:\n"); show_diff(B, LEN(B), A, LEN(A));
	printf("\nA ^ B:\n");  show_sym_diff(A, LEN(A), B, LEN(B));

	return 0;
}










Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference





Java: Set<String> setA = new Set<String>{'John', 'Bob', 'Mary', 'Serena'};
Set<String> setB = new Set<String>{'Jim', 'Mary', 'John', 'Bob'};


Set<String> notInSetA = setB.clone();
notInSetA.removeAll(setA);

Set<String> notInSetB = setA.clone();
notInSetB.removeAll(setB);

Set<String> symmetricDifference = new Set<String>();
symmetricDifference.addAll(notInSetA);
symmetricDifference.addAll(notInSetB);


Set<String> union = setA.clone();
union.addAll(setB);

Set<String> intersection = setA.clone();
intersection.retainAll(setB);

Set<String> symmetricDifference2 = union.clone();
symmetricDifference2.removeAll(intersection);

System.debug('Not in set A: ' + notInSetA);
System.debug('Not in set B: ' + notInSetB);
System.debug('Symmetric Difference: ' + symmetricDifference);
System.debug('Symmetric Difference 2: ' + symmetricDifference2);






Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference







Python: >>> setA = {"John", "Bob", "Mary", "Serena"}
>>> setB = {"Jim", "Mary", "John", "Bob"}
>>> setA ^ setB 
{'Jim', 'Serena'}
>>> setA - setB 
{'Serena'}
>>> setB - setA 
{'Jim'}
>>> setA | setB 
{'John', 'Bob', 'Jim', 'Serena', 'Mary'}
>>> setA & setB 
{'Bob', 'John', 'Mary'}




Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference






PHP: <?php
$a = array('John', 'Bob', 'Mary', 'Serena');
$b = array('Jim', 'Mary', 'John', 'Bob');

$a = array_unique($a);
$b = array_unique($b);

$a_minus_b = array_diff($a, $b);
$b_minus_a = array_diff($b, $a);

$symmetric_difference = array_merge($a_minus_b, $b_minus_a);

echo 'List A:               ', implode(', ', $a),
   "\nList B:               ", implode(', ', $b),
  "\nA \\ B:                ", implode(', ', $a_minus_b),
  "\nB \\ A:                ", implode(', ', $b_minus_a),
   "\nSymmetric difference: ", implode(', ', $symmetric_difference), "\n";
?>





Fortran: program Symmetric_difference
implicit none

  character(6) :: a(4) = (/ "John  ", "Bob   ", "Mary  ", "Serena" /)
  character(6) :: b(4) = (/ "Jim   ", "Mary  ", "John  ", "Bob   " /)
  integer :: i, j

outer1: do i = 1, size(a)
          do j = 1, i-1
            if(a(i) == a(j)) cycle outer1   
          end do
          if(.not. any(b == a(i))) write(*,*) a(i)
        end do outer1
  
outer2: do i = 1, size(b)
          do j = 1, i-1
            if(b(i) == b(j)) cycle outer2   
          end do
          if(.not. any(a == b(i))) write(*,*) b(i)
        end do outer2
      
end program
Task: Symmetric difference






PHP: <?php
$a = array('John', 'Bob', 'Mary', 'Serena');
$b = array('Jim', 'Mary', 'John', 'Bob');

$a = array_unique($a);
$b = array_unique($b);

$a_minus_b = array_diff($a, $b);
$b_minus_a = array_diff($b, $a);

$symmetric_difference = array_merge($a_minus_b, $b_minus_a);

echo 'List A:               ', implode(', ', $a),
   "\nList B:               ", implode(', ', $b),
  "\nA \\ B:                ", implode(', ', $a_minus_b),
  "\nB \\ A:                ", implode(', ', $b_minus_a),
   "\nSymmetric difference: ", implode(', ', $symmetric_difference), "\n";
?>
Task: Symmetric difference






PHP: <?php
$a = array('John', 'Bob', 'Mary', 'Serena');
$b = array('Jim', 'Mary', 'John', 'Bob');

$a = array_unique($a);
$b = array_unique($b);

$a_minus_b = array_diff($a, $b);
$b_minus_a = array_diff($b, $a);

$symmetric_difference = array_merge($a_minus_b, $b_minus_a);

echo 'List A:               ', implode(', ', $a),
   "\nList B:               ", implode(', ', $b),
  "\nA \\ B:                ", implode(', ', $a_minus_b),
  "\nB \\ A:                ", implode(', ', $b_minus_a),
   "\nSymmetric difference: ", implode(', ', $symmetric_difference), "\n";
?>






Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_XOR is
   type Person is (John, Bob, Mary, Serena, Jim);
   type Group is array (Person) of Boolean;
   procedure Put (Set : Group) is
      First : Boolean := True;
   begin
      for I in Set'Range loop
         if Set (I) then
            if First then
               First := False;
            else
               Put (',');
            end if;
            Put (Person'Image (I));
         end if;
      end loop;
   end Put;

   A : Group := (John | Bob | Mary | Serena => True, others => False);
   B : Group := (Jim | Mary | John | Bob    => True, others => False);   
begin
   Put ("A xor B = "); Put (A xor B);     New_Line;
   Put ("A - B   = "); Put (A and not B); New_Line;
   Put ("B - A   = "); Put (B and not A); New_Line;
end Test_XOR;
Task: Inheritance_Single



C#: class Animal
{ 
   
  
}

class Dog : Animal
{ 
   
  
}

class Lab : Dog
{ 
   
  
}

class Collie : Dog
{ 
  
  
}

class Cat : Animal
{ 
  
  
}









Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single


C++: class Animal
{
  
};

class Dog: public Animal
{
  
};

class Lab: public Dog
{
  
};

class Collie: public Dog
{
  
};

class Cat: public Animal
{
  
};










Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single




Go: package main

type animal struct {
    alive bool
}

type dog struct {
    animal
    obedienceTrained bool
}

type cat struct {
    animal
    litterBoxTrained bool
}

type lab struct {
    dog
    color string
}

type collie struct {
    dog
    catchesFrisbee bool
}

func main() {
    var pet lab
    pet.alive = true
    pet.obedienceTrained = false
    pet.color = "yellow"
}








Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single





Java: public class Animal{
   
}







Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single







Python: class Animal:
  pass 

class Dog(Animal):
  pass 

class Cat(Animal):
  pass 

class Lab(Dog):
  pass 

class Collie(Dog):
  pass 





Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single








VB: Class Animal
  
End Class

Class Dog
  Inherits Animal
  
End Class

Class Lab
  Inherits Dog
  
End Class

Class Collie
  Inherits Dog
  
End Class

Class Cat
  Inherits Animal
  
End Class




Ada: package Inheritance is
   type Animal is tagged private;
   type Dog is new Animal with private;
   type Cat is new Animal with private;
   type Lab is new Dog with private;
   type Collie is new Dog with private;
private
   type Animal is tagged null record;
   type Dog is new Animal with null record;
   type Cat is new Animal with null record;
   type Lab is new Dog with null record;
   type Collie is new Dog with null record;
end Inheritance;
Task: Inheritance_Single



C#: class Animal
{ 
   
  
}

class Dog : Animal
{ 
   
  
}

class Lab : Dog
{ 
   
  
}

class Collie : Dog
{ 
  
  
}

class Cat : Animal
{ 
  
  
}
Task: Inheritance_Single


C++: class Animal
{
  
};

class Dog: public Animal
{
  
};

class Lab: public Dog
{
  
};

class Collie: public Dog
{
  
};

class Cat: public Animal
{
  
};
Task: Inheritance_Single





Java: public class Animal{
   
}
Task: Inheritance_Single







Python: class Animal:
  pass 

class Dog(Animal):
  pass 

class Cat(Animal):
  pass 

class Lab(Dog):
  pass 

class Collie(Dog):
  pass
Task: Inheritance_Single








VB: Class Animal
  
End Class

Class Dog
  Inherits Animal
  
End Class

Class Lab
  Inherits Dog
  
End Class

Class Collie
  Inherits Dog
  
End Class

Class Cat
  Inherits Animal
  
End Class
Task: Inheritance_Single




Go: package main

type animal struct {
    alive bool
}

type dog struct {
    animal
    obedienceTrained bool
}

type cat struct {
    animal
    litterBoxTrained bool
}

type lab struct {
    dog
    color string
}

type collie struct {
    dog
    catchesFrisbee bool
}

func main() {
    var pet lab
    pet.alive = true
    pet.obedienceTrained = false
    pet.color = "yellow"
}
Task: Inheritance_Single



C#: class Animal
{ 
   
  
}

class Dog : Animal
{ 
   
  
}

class Lab : Dog
{ 
   
  
}

class Collie : Dog
{ 
  
  
}

class Cat : Animal
{ 
  
  
}








Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single


C++: class Animal
{
  
};

class Dog: public Animal
{
  
};

class Lab: public Dog
{
  
};

class Collie: public Dog
{
  
};

class Cat: public Animal
{
  
};









Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single





Java: public class Animal{
   
}






Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single







Python: class Animal:
  pass 

class Dog(Animal):
  pass 

class Cat(Animal):
  pass 

class Lab(Dog):
  pass 

class Collie(Dog):
  pass 




Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single








VB: Class Animal
  
End Class

Class Dog
  Inherits Animal
  
End Class

Class Lab
  Inherits Dog
  
End Class

Class Collie
  Inherits Dog
  
End Class

Class Cat
  Inherits Animal
  
End Class



Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single






PHP: class Animal {

}

class Dog extends Animal {

}

class Cat extends Animal {

}

class Lab extends Dog {

}

class Collie extends Dog {

}





Fortran: module anim

  type animal
  end type animal

  type, extends(animal) :: dog
  end type dog

  type, extends(animal) :: cat
  end type cat

  type, extends(dog) :: lab
  end type lab

  type, extends(dog) :: collie
  end type collie

end module anim
Task: Inheritance_Single



C#: class Animal
{ 
   
  
}

class Dog : Animal
{ 
   
  
}

class Lab : Dog
{ 
   
  
}

class Collie : Dog
{ 
  
  
}

class Cat : Animal
{ 
  
  
}







COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single


C++: class Animal
{
  
};

class Dog: public Animal
{
  
};

class Lab: public Dog
{
  
};

class Collie: public Dog
{
  
};

class Cat: public Animal
{
  
};








COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single





Java: public class Animal{
   
}





COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single







Python: class Animal:
  pass 

class Dog(Animal):
  pass 

class Cat(Animal):
  pass 

class Lab(Dog):
  pass 

class Collie(Dog):
  pass 



COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single








VB: Class Animal
  
End Class

Class Dog
  Inherits Animal
  
End Class

Class Lab
  Inherits Dog
  
End Class

Class Collie
  Inherits Dog
  
End Class

Class Cat
  Inherits Animal
  
End Class


COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single




Go: package main

type animal struct {
    alive bool
}

type dog struct {
    animal
    obedienceTrained bool
}

type cat struct {
    animal
    litterBoxTrained bool
}

type lab struct {
    dog
    color string
}

type collie struct {
    dog
    catchesFrisbee bool
}

func main() {
    var pet lab
    pet.alive = true
    pet.obedienceTrained = false
    pet.color = "yellow"
}






COBOL:        CLASS-ID. Animal.
           
       END CLASS Animal.
       
       CLASS-ID. Dog INHERITS Animal.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal.

           
       END CLASS Dog.
       
       CLASS-ID. Cat INHERITS Animal. 
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Animal. 

           
       END CLASS Cat.
           
       CLASS-ID. Lab INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Lab.
       
       CLASS-ID. Collie INHERITS Dog.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           CLASS Dog.

           
       END CLASS Collie.
Task: Inheritance_Single






PHP: class Animal {

}

class Dog extends Animal {

}

class Cat extends Animal {

}

class Lab extends Dog {

}

class Collie extends Dog {

}