To make me your default constructor & amp; To start all items shown in my code snippet, I would like to call my parametric constructor to call the default constructor, so to create and start those objects, which, without the null reference expression in the paramedical constructor Can be used.
In this situation, I am not really sure that the best (the most efficient, low code, etc.) way to use the consultants, I like to use constructor channing.
Again, I have a very basic understanding of constructors, so if this is not possible, please tell me, and tell what will you do in this situation.
square rectangle {left public line {get; Set; } Public Line Top {Received; Set; } Receive the public line correct; Set; } Public line {received; Set; } Public Rectangle (): This (New Line ()) {} Public Rectangle (Line Diagnostics) {Left = New Line (); Top = new line (); Correct = new line (); Down = new line (); Point start application DiagonalPoint = new point (); Point ending point = new point (); Beginner violet point = diagnosis Startpoint; Finished Degonial Point = Diagnosis End Point; Int begXC = beginner GnialPoint XCoord; Int begYC = ExternalDioialPoint ICoord; Int endXC = Finished DeGonel Point.xCoord; Int endYC = Finished DeGonel Point. ICoord; Point Writersend = New Point (); RightSideEnd.xCoord = endXC; RightSideEnd.yCoord = begYC; Point leftand = new point (); LeftSideEnd.xCoord = begXC; LeftSideEnd.yCoord = endYC; // ----------- Right Definitions ------------- right.startPoint = Finished Degonial Point; Right.endPoint = rightSideEnd; // ------------ Definitions of left side -------------- left.startPoint = startDiagonalPoint; Left.endPoint = leftSideEnd; // ------------ Top side definition ------------- top.startPoint = leftSideEnd; Top.endPoint = Finished DeGonel Point; // ------------ Down Definitions ----------- Below Start page = right sideend; Bottom.endPoint = StartDonePoint; Typically when you have chain constants it's a way around: Default Constructor calls with more specific constructors, with default values. Say you have a point constructor that takes X and Y coordinates. After that, you have the default point constructor called X = 0 and Y = 0. In this way, you only have to type the code to set the value once. Here are some things that you can improve in your code:
-
You can start for the new code and < Code> initialize the deagonable point
and then you overwrite them with reference to diagnostic .startPoint
and diagnonal.endPoint
. You are making two new points and then leaving them. You do not need to make those new points.
-
You create new consultants and new lines with the default constructor and set your fields manually. You can create a point constructor which gets two coordinates and sets them, and a line constructor that gets two end points and sets them. Your code will look like this:
Right Sarvank = New point (AndXC, BEGIC); Point leftand = new point (BGXC, ANDYC); Right = New Line (Finished Degonial Point, Right Sideend); Left = new line (start application, leftendend); Top = new line (left sideend, end to denotiable point); Down = new line (right sideend, beginning application dagoni);
No comments:
Post a Comment