问题描述
更新的问题。在这段代码中,我定义了一个记录类型,该记录类型包含特定物种的大量数据。我想编写一条if语句,将用户的“ Specied_Type”输入与“ Species_Type(Human,Elf,....)”中已经存在的数据进行比较。有什么建议吗?
我的代码:
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
procedure Hero is
type Species_Type is(Human,Elf,Lizardman,Halfling); --Line 8
type Eye_Type is (Blue,Green,brown,Gray,Black);
package Species_Type_IO is new Enumeration_IO (Species_Type);
use Species_Type_IO;
package Eye_Type_IO is new Enumeration_IO (Eye_Type); use Eye_Type_IO;
type Hero_Type is
record
Name: Unbounded_String;
Age: Integer;
Gender:Unbounded_String;
weight: Float;
Haircolor: Unbounded_String;
Species: Species_Type;
Eyecolor: Eye_Type;
end record;
A: Hero_Type;
Procedure Get(Item: out Hero_Type) is
begin
Put("Name: "); Item.Name:= Get_Line;
Put_Line("Name: " & Item.Name);
Put("Age: "); Get(Item.Age); Put("Age: " & Integer'Image (Item.Age));
New_Line;
Put("Species: "); Get(Item.Species); Put("Species: ");
Put(Item.Species,set => Lower_Case); New_Line;
Put("Eye color: "); Get(Item.Eyecolor); Put_Line("Color:
"&Eye_Type'Image(Item.Eyecolor));
if Item.Species /= A.Species then --Does not seem right
Put("Wrong input"); end if;
begin
Get(A);
end Hero;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)