How to resolve the algorithm Compound data type step by step in the Objeck programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Compound data type step by step in the Objeck programming language

Table of Contents

Problem Statement

Create a compound data type:

A compound data type is one that holds multiple independent values.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Compound data type step by step in the Objeck programming language

Source code in the objeck programming language

class Point {
  @x : Int;
  @y : Int;

  New() { 
    @x := 0;
    @y := 0;
  }

  New(x : Int, y : Int) { 
    @x := x;
    @y := y;
  }

  New(p : Point) { 
    @x := p->GetX();
    @y := p->GetY();
  }

  method : public : GetX() ~ Int { 
    return @x; 
  }

  method : public : GetY() ~ Int { 
    return @y; 
  }

  method : public : SetX(x : Int) ~ Nil { 
    @x := x; 
  }

  method : public : SetY(y : Int) ~ Nil { 
    @y := y; 
  }
}

  

You may also check:How to resolve the algorithm Increment a numerical string step by step in the Seed7 programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the OCaml programming language
You may also check:How to resolve the algorithm Sierpinski triangle/Graphical step by step in the ActionScript programming language
You may also check:How to resolve the algorithm Calendar step by step in the BASIC programming language
You may also check:How to resolve the algorithm Sequence of non-squares step by step in the HicEst programming language