source: tol/TolJava/TOLJava/src/com/hcarralero/toljava/TOLReal.java @ 9887b93

1941-docker-image-to-testdevel
Last change on this file since 9887b93 was 9887b93, checked in by Humberto Carralero <hacarralero@…>, 15 years ago

Importing TolJava

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3900 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.3 KB
Line 
1
2package com.hcarralero.toljava;
3
4/**
5 * Representa a un objeto TOL de tipo Real.
6 *
7 * @author Humberto Andrés Carralero López (hcarralero@gmail.com)
8 * @version 1.0
9 */
10public class TOLReal extends TOLLObject {
11
12    private double value= 0.0;
13
14    /**
15     * Construye un objeto de tipo <code>TOLReal</code> a partir de un náž¿ero real
16     *
17     * @param value el valor real que representa
18     */
19    public TOLReal(double value) {
20        this.value = value;
21    }
22
23    /**
24     * Obtiene el valor numérico real almacenado
25     *
26     * @return el valor numérico real almacenado
27     */
28    public double getValue() {
29        return value;
30    }
31
32    /**
33     * Cambia el valor numérico real almacenado por el valor pasado como parámetro
34     *
35     * @param value nuevo valor numérico real
36     */
37    public void setValue(double value) {
38        this.value = value;
39    }
40
41    /**
42     * Determina si el objeto corresponde al tipo Real de TOL
43     *
44     * @return <code>true</code> ya que el objeto corresponde al tipo Real de TOL
45     */
46    @Override
47    public boolean isReal() {
48        return true;
49    }
50
51    /**
52     * Compara a este objeto con otro
53     
54     * @param obj el objeto con el que se comparará
55     * @return <code>true</code> si el objeto pasado como parámetro es de tipo <code>TOLReal</code> y contiene un valor numérico real idéntico
56     */
57    @Override
58    public boolean equals(Object obj) {
59        if (obj == null) {
60            return false;
61        }
62        if (getClass() != obj.getClass()) {
63            return false;
64        }
65        final TOLReal other = (TOLReal) obj;
66        if (this.value == other.value) {
67            return true;
68        }
69        return false;
70    }
71
72    /**
73     * Calcula el código hash asignado al objeto
74     *
75     * @return el código hash asignado al objeto
76     */
77    @Override
78    public int hashCode() {
79        int hash = 5;
80        hash = 67 * hash + (int) (Double.doubleToLongBits(this.value) ^ (Double.doubleToLongBits(this.value) >>> 32));
81        return hash;
82    }
83
84    /**
85     * Obtiene una representación como cadena de texto del valor numérico real
86     *
87     * @return la representación como cadena de texto del valor numérico real
88     */
89    @Override
90    public String toString() {
91        return ""+this.value;
92    }
93
94}
Note: See TracBrowser for help on using the repository browser.