354 Object-Oriented Programming: Inheritance Chapter 9 It appears (How to cite a web site)
354 Object-Oriented Programming: Inheritance Chapter 9 It appears that we literally copied code from class Point, pasted this code in the code from class Circle, then modified class Circle to include a radius. This copy-andpaste approach is often error-prone and time-consuming. Worse yet, it can result in many physical copies of the code existing throughout a system, creating a code-maintenance nightmare. Is there a way to absorb the attributes and behaviors of one class in a way that makes them part of other classes without duplicating code? 1 // Fig. 9.7: CircleTest.cs 2 // Testing class Circle. 3 4 using System; 5 using System.Windows.Forms; 6 7 // CircleTest class definition 8 class CircleTest 9 { 10 // main entry point for application. 11 static void Main( string[] args ) 12 { 13 // instantiate Circle 14 Circle circle = new Circle( 37, 43, 2.5 ); 15 16 // get Circle’s initial x-y coordinates and radius 17 string output = “X coordinate is ” + circle.X + 18 “nY coordinate is ” + circle.Y + “nRadius is ” + 19 circle.Radius; 20 21 // set Circle’s x-y coordinates and radius to new values 22 circle.X = 2; 23 circle.Y = 2; 24 circle.Radius = 4.25; 25 26 // display Circle’s string representation 27 output += “nnThe new location and radius of ” + 28 “circle are n” + circle + “n”; 29 30 // display Circle’s diameter 31 output += “Diameter is ” + 32 String.Format( “{0:F}”, circle.Diameter() ) + “n”; 33 34 // display Circle’s circumference 35 output += “Circumference is ” + 36 String.Format( “{0:F}”, circle.Circumference() ) + “n”; 37 38 // display Circle’s area 39 output += “Area is ” + 40 String.Format( “{0:F}”, circle.Area() ); 41 42 MessageBox.Show( output, “Demonstrating Class Circle” ); 43 44 } // end method Main Fig. 9.7 Fig. 9.7Fig. 9.FiFi7g. 9.7g. 9.7CircleTestdemonstrates class Circlefunctionality. (Part 1 of 2.)
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.