oop-labs-collection/labs/5/Symbol.java

67 lines
1.8 KiB
Java
Raw Normal View History

2023-06-10 15:50:10 +03:00
/*
* %W% %E% Dymik739
* Email: dymik739@109.86.70.81
*
* Copyright (C) 2023 FIOT Dev Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Class which represents a single character and replaces the default
* 'char' data type.
*
* @since 0.2
* @author Dymik739
*/
public class Symbol {
2023-06-10 15:50:10 +03:00
/** contains character that the object represents. */
private char symbol;
2023-06-10 15:50:10 +03:00
/**
* Constructor which creates this object using a single char.
*
* @since the_world_was_created
* @param symbol character this object represents
*/
public Symbol(char symbol) {
this.symbol = symbol;
}
2023-06-10 15:50:10 +03:00
/**
* Method used to get a proper String representation of this symbol.
*
* @since 0.2
* @return String representation of this symbol
*/
@Override
public String toString() {
char[] arr = new char[1];
arr[0] = this.symbol;
return new String(arr);
}
2023-06-10 15:50:10 +03:00
/**
* Method used to compare two symbols.
*
* @since 0.2
* @param o another symbol to compare to
* @return true if symbols are the same, false otherwise
*/
public boolean equals(Symbol o) {
return this.symbol == o.symbol;
}
}