联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2018-07-24 09:40


public enum Colour {

WHITE('.'),

BLACK('*');

// character for printing as text

char texture;

Colour(char texture) {

this.texture = texture;

}

/**

* Returns a character representation of this colour, to be

used for rendering as a string.

*

* @return a character representation of this colour

*/

public char getTexture() {

return this.texture;

}

/**

* Returns a string representation of this colour.

*

* @return a string representation of this colour

*/

public String toString() {

return Character.toString(texture);

}

/**

* Returns true if the unicode code point given by the

input corresponds to the texture of

* a valid colour.

*

* @param c a unicode code point

* @return true if c corresponds to a valid colour, false

otherwise

*/

public static boolean isTexture(int c) {

if (!Character.isBmpCodePoint(c)) {

return false;

}

char ch = (char)c;

for (Colour colour : Colour.values()) {

if (colour.texture == ch) {

return true;

}

}

return false;

}

}


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp