comp.lang.ada
 help / color / mirror / Atom feed
* Need some help in Ada
@ 2016-03-23 19:29 danifreecs
  2016-03-23 19:51 ` Anh Vo
  2016-03-23 21:18 ` danifreecs
  0 siblings, 2 replies; 9+ messages in thread
From: danifreecs @ 2016-03-23 19:29 UTC (permalink / raw)


Hello there!

I'm a student, and i've got my 1st home project in Ada. I need to implement a J_String package with a lot of functions etc, but i have problems at the start. The specification asks me to "implement J_String type as an opaque discriminant record type. For the inner representation of the string use the Standard String type. The discriminant determines the size of the string, which is contained in the J_String type."

My .ads at the moment:

package J_String_Pkg is
  type J_String(Size: Natural) is private;
  private
    type J_String(Size: Natural) is record
      Components: String(Natural Range 0..Natural'Last);
      end record;
end J_String_Pkg;

I don't know if the above is good, but the main reason i'm asking help is the following methods:
function Create(Str : String) return J_String;
--Creates a J_String from a String
function Value_Of(S : J_String) return String;
--Returns the content of S in String type
function Is_Empty(S : J_String) return Boolean; 
-- Returns true if, and only if, length() is 0.

I think i can do the other 20+ methods, but i can't figure out how to make my J_String type to be able to create empty strings. Thanks for every help!


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-23 21:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-23 19:29 Need some help in Ada danifreecs
2016-03-23 19:51 ` Anh Vo
2016-03-23 20:24   ` danifreecs
2016-03-23 20:52     ` Anh Vo
2016-03-23 21:11       ` danifreecs
2016-03-23 21:34         ` Anh Vo
2016-03-23 21:06     ` Robert A Duff
2016-03-23 21:10     ` Niklas Holsti
2016-03-23 21:18 ` danifreecs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox