Note If you don’t know how to solve an problem, or what is the function to be used, you could search on Internet for the answer using the API of the Java programming language. Indeed, since SARL is fully compatible with the Java API, you could use all the types or functions that are defined in this Java API.
Write a SARL program to create a class and display the package (or namespace) of that class.
Write a SARL program to create an instance of a specified class and display the package (or namespace) of the said instance.
Write a SARL program that imports the abs()
function from the java.lang.Math
class using the import
statement, and finds the absolute value of -155
.
Define a class that is repsenting a student, with her/her name and age as attributes, and the associated getter/setter functions.
Define a class that is repsenting a student, with her/her name and age as attributes, without implementing the getter/setter functions. The getter/setter functions must be automatically generatd by the SARL compiler.
Write a SARL program to create two empty classes, Student
and Marks
. Now create some instances and check whether they are instances of the said classes or not. Also, check whether the said classes are subclasses of the built-in object class or not.
Write a SARL class named Student with two instances student1, student2 and assign values to the instances’ attributes. Print all the attributes of the student1, student2 instances with their values.
Define a class that is representing a student, with her/her name, age and marks as attributes, and the associated getter/setter functions.
Define a second class named Main
that is creating an instance of the student class.
How to simulate the addition of the method s.means()
, that is computing the mean of the marks of the student s
without changing the code of the student class?
Write a SARL class to convert an integer to a Roman numeral.
Write a SARL class to convert a Roman numeral to an integer.
Write a SARL class, named Vector
that is representing a 2D vector of values (x, y)
. Implements the function that enables to sum two vectors, named add()
.
(x=124, y=45)
and (x=-456, y=78)
(x=-332, y=123)
Update the class, named Vector
, with the definition of the operation +
that sums two vectors. Use this operator to sum two vectors instead of calling the add()
function.
(x=124, y=45)
and (x=-456, y=78)
(x=-332, y=123)
Copyright © 2014-2024 SARL.io, the Original Authors and Main Authors.
Documentation text and medias are licensed under the Creative Common CC-BY-SA-4.0; you may not use this file except in compliance with CC-BY-SA-4.0. You may obtain a copy of CC-BY-4.0.
Examples of SARL code are licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the Apache License. You may obtain a copy of the Apache License.
You are free to reproduce the content of this page on copyleft websites such as Wikipedia.
Generated with the translator docs.generator 0.14.0.