Attribute Image
capitalizes all characters of enumeration literals. The function Case_Rule_For_Names
applies upper case for the first character and makes the rest lower case.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure Main is
type Fruit is (Banana, Pear, Orange, Melon);
function Case_Rule_For_Names (Item : String) return String is
begin
return Translate (Item (Item'First .. Item'First), Upper_Case_Map) & Translate (Item (Item'First + 1 .. Item'Last), Lower_Case_Map);
end;
begin
for I in Fruit loop
Put (Case_Rule_For_Names (Fruit'Image (I)));
New_Line;
end loop;
end;
Banana
Pear
Orange
Melon