1 / 2

Primitiv forbindelse til 0.1 objekt

Primitiv forbindelse til 0.1 objekt. class AClass { private BClass bObj; // Pre: BObject må ikke være null // Post: bObject tilknyttet dette AClass object public void Connect_Primitive(BClass bObjectet) {

eliot
Download Presentation

Primitiv forbindelse til 0.1 objekt

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Primitiv forbindelse til 0.1 objekt class AClass { private BClass bObj; // Pre: BObject må ikke være null // Post: bObject tilknyttet dette AClass object public void Connect_Primitive(BClass bObjectet) { this.bObj = bObjectet; // ligner simpel værditildeling } // Pre: ingen // Post: bObject ikke mere tilknyttet dette AClass object public void Disconnect_Primitive() { this.bObj = null; // ligner simpel værditildeling } // Pre: ingen // Post: returnere true hvis bObject connected ellers false public bool IsConnected_Primitive(BClass bObjectet) { return this.bObj == bObjectet; } }

  2. Primitiv forbindelse til 0.* objekter class AClass { private List<BClass> bObjListe = new List<BClass>(); // Pre: BObject må ikke være null og må ikke allerede tilknyttet // Post: bObject tilknyttet dette AClass object public void PrimitiveConnect(BClass bObjectet) { this.bObjListe.Add(bObjectet); // Tilføj til listen } // Pre: ingen // Post: bObject ikke mere tilknyttet dette AClass object public void PrimitiveDisconnect(BClass bObjectet) { this.bObjListe.Remove(bObjectet); // fjern fra listen } // Pre: ingen // Post: returnere true hvis bObject connected ellers false public bool IsConnected_Primitive(BClass bObjectet) { return this.bObjListe.Contains(bObjectet); } }

More Related