This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Table of Contents1.0 INTRODUCTION.................................................................................................................................2
4.1 TEST PLAN........................................................................................................................................13
4.2 TEST LOG..........................................................................................................................................14
Appendix I USER GUIDE........................................................................................................................19
1
1.0 INTRODUCTIONTechnology today has become relevant in every sphere of life with its applications bringing about an ease in the way we carry out our day to day activities. This has led to an introduction of computerization in most regular activities such as mathematical calculations which in turn brings about a greater rate of accuracy and efficiency in these so called mathematical calculations. This program is console based and is meant to receive input from the user of the x, y and z co-ordinates of two points and then go ahead to calculate the distance between these two points in both 2D and 3D, and to plot these points on the console
2
2.0 SOURCE CODE
2.1 CLASS COORDINATETESTusing System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{ class CoordinateTest { static void Main(string[] args) {
int[] num; num = new int[6];
Console.WriteLine("\t********* WELCOME TO THE COORDINATE TEST PROGRAM ***********"); Console.WriteLine("\t***************** THIS PROGRAM CALCULATES *******************"); Console.WriteLine("\t***** THE DISTANCE IN 2D AND 3D BETWEEN ANY TWO POINTS ******\n\n\n");
Console.Write("\nEnter value of x for 1st 2D Constructor : "); int x1= Convert.ToInt32(Console.ReadLine()); num[0] = x1;
Console.Write("Enter value of y for 1st 2D Constructor : "); int y1 = Convert.ToInt32(Console.ReadLine()); num[1] = y1;
Console.Write("Enter value of z for 1st 3D Constructor : "); int z1 = Convert.ToInt32(Console.ReadLine()); num[2] = z1;
Console.Write("Enter value of x for 2nd 2D Constructor : "); int x2 = Convert.ToInt32(Console.ReadLine()); num[3] = x2;
Console.Write("Enter value of y for 2nd 2D Constructor : "); int y2 = Convert.ToInt32(Console.ReadLine()); num[4] = y2;
Console.Write("Enter value of z for 2nd 3D Constructor : "); int z2= Convert.ToInt32(Console.ReadLine()); num[5] = z2;
Class2DPoint object1 = new Class2DPoint(num[0], num[1]); Class2DPoint object2 = new Class2DPoint(num[3], num[4]); Class3DPoint object3 = new Class3DPoint(num[0], num[1], num[2]); Class3DPoint object4 = new Class3DPoint(num[3], num[4], num[5]);
Console.WriteLine("The Graphical representation of point in graph\n\n");
3
object2.drawGraph(object3, object4);
object1 = object1 - object4; Console.Write("\n\n2DPoints, Distance between A and B is: "); object1.showDistance(object2); object2 = object3 * object4; Console.Write("\n3DPoints, Distance between A and B is: "); object3.showDistance(object4);
Console.Write("\nPress the Enter key to Exit");
Console.ReadLine(); } }}
2.2 CLASS CLASS2DPOINTusing System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{ public class Class2DPoint { protected int x; protected int y;
public Class2DPoint() { this.x = 0; this.y = 0; } public Class2DPoint(int x, int y) { this.x = x; this.y = y; } public double showDistance(Class2DPoint secondPoint) { int x1 = this.x; int y1 = this.y; int x2 = secondPoint.x; int y2 = secondPoint.y; double distance = Math.Sqrt(Math.Pow((x2 - x1), 2.0) + Math.Pow((y2 - y1), 2.0)); Console.WriteLine(distance); return distance; } public static Class2DPoint operator -(Class2DPoint object1, Class2DPoint object2) { Class2DPoint OO = new Class2DPoint();
3.2 DATA DICTIONARY - = {private}# = {protected}+ = {public}() = {constructor}Int = {32bit numeric}String = {alphabet + numeric + (ASCII code)}x = {value of 1st Class2DPoint constructor + value of 2nd Class2DPoint constructor}y = {value of 1st Class3DPoint constructor + value of 2nd Class3DPoint constructor}z = {value of Class3DPoint }Class2Dpoint = {distance + position + 2D object}Class3Dpoint = {distance + position + 3D object}drawGraph = {graph + distance of Class2DPoint + distance of Class3DPoint}showDistance ={ display distance of Class2DPoint + Class3Dpoint}Inheritance = { attributes of Class2DPoint + extra attributes of Class3DPoint
8
3.3 PSEUDO CODEStart
ConsolePrintLine “WELCOME TO 2D AND 3D POINT CALCULATOR”
“THIS PROGRAM CALCULATES”
"THE DISTANCE IN 2D AND 3D BETWEEN ANY TWO POINTS”
ConsoleWriteline “Enter the value of x for 1st 2D constructor”
Console.ReadLine();
Console Writeline “Enter the value of y for 1st 2D constructor”
Console.ReadLine();
ConsoleWriteline “Enter the value of z for 1st 3D constructor”
Console.ReadLine();
ConsolePrintLine“Enter the value of x for 2nd 2D constructor”
Console.ReadLine();
ConsoleWriteline “Enter the value of y for 2nd 2D constructor”
Console.ReadLine();
ConsolePrintLine “Enter the value of z for 2nd 3D constructor”
Console.ReadLine();
ConsolePrintLine “The graphical representation of point in graph”
ConsolePrintLine “2D points distance between A and B is = output answer”
ConsolePrintLine “3D points distance between A and B is = output answer”
ConsolePrintLine “Enter any key to exit”
End
9
3.4 FLOWCHART
10
A
Console.ReadLine();
ConsoleWriteline “Enter the value of y for 1st 2D constructor”
Console.ReadLine();
ConsoleWriteline “Enter the value of x for 1st 2D constructor”
ConsolePrintLine “WELCOME TO 2D AND 3D POINT CALCULATOR”
“THIS PROGRAM CALCULATES”
"THE DISTANCE IN 2D AND 3D BETWEEN ANY TWO POINTS”
start
11
12
4.0 TESTING
4.1 TEST PLANTest No.
Purpose of Test Test Data Expected Result Pass/Fail
Date
1 Test welcome message
“WELCOME TO 2D AND 3D POINT
CALCULATOR”“THIS PROGRAM CALCULATES”
"THE DISTANCE IN 2D AND 3D
BETWEEN ANY TWO POINTS”
Program should be able to display “WELCOME TO 2D AND 3D
POINT CALCULATOR”“THIS PROGRAM CALCULATES”
"THE DISTANCE IN 2D AND 3D BETWEEN ANY TWO
POINTS”
Pass 19/08/2010
2 Test input for 1st x co-ordinate
“3” Program should be able to receive integer input “3”
Pass 19/08/2010
3 Test input for 1st y co-ordinate
“5” Program should be able to receive integer input “5”
pass 19/08/2010
4 Test input for 1st z co-ordinate
“4” Program should be able to receive integer input “4”
pass 19/08/2010
5 Test input for 2nd x co-ordinate
“5” Program should be able to receive integer input “5”
pass 19/08/2010
6 Test input for 2nd y co-ordinate
“7” Program should be able to receive integer input “7”
Pass 19/08/2010
7 Test input for 2nd z co-ordinate
“6” Program should be able to receive integer input “6”
pass 19/08/2010
13
8 Test for 2DPoints, Distance between A and B
“ calculated 2Dpoints distance answer”
Program should be able to display the answer of the calculated distance between A and B
pass 19/08/2010
9 Test for 3DPoints, Distance between A and B
“ calculated distance 3Dpoints answer”
Program should be to calculate and display the answer of the both 2Dpoints and 3Dpointd.
Pass 19/082010
10 Test for display of 2dpoints and 3dpoints on graph.
“2Dpoints and 3Dpoints answer on graph”
Program should be able to display the result of 2Dpoints and 3Dpoints on the graph.
pass 19/08/2010
4.2 TEST LOG
Test No.(see Test plan)
Purpose of Test Actual Result ResultPass/Fail
Comment Date
1 Test welcome message
“WELCOME TO 2D AND 3D
POINT CALCULATOR”
“THIS PROGRAM CALCULATES”
"THE DISTANCE IN 2D AND 3D BETWEEN ANY TWO POINTS”
Pass Program display the welcome message to user.
19/08/2010
2 Test for 1st x co-ordinate
“3” Pass Program was able to receive integer as put for 1st x co-ordinate
19/08/2010
3 Test for 1st y co-ordinate
“5” Pass Program was able to receive integer as put for 1st y co-ordinate
19/08/2010
4 Test for 1st z co-ordinate
“4” Pass Program was able to receive integer as put for 1st z co-ordinate
19/08/2010
5 Test for 2nd x co-ordinate
“5” Pass Program was able to receive integer as put for 2nd x co-ordinate
19/08/2010
6 Test for 2nd y co-ordinate
“7” Pass Program was able to receive integer as put for 2nd y co-ordinate
19/08/2010
14
7 Test for 2nd z co-ordinate
“6” Pass Program was able to receive integer as put for 2nd z co-ordinate
19/08/2010
8 Test for 2DPoints, Distance between A and B
“14.2126704035519”
Pass Program was able to calculate and display result
19/08/2010
9 Test for 3DPoints, Distance between A and B
“3.46410161513775”
Pass Program was able to display 3Dpoints result
19/08/2010
10 Test for display of 2dpoints and 3dpoints on graph
B
A
Pass Program was able to display the position of the A and B co-ordinates on the graph.
19/08/2010
4.3 PRINT SCREEN
Fig1: The welcome screen
15
Fig2: The input of the x, y and z coordinates for the 2D and 3D points
16
Fig3: The graph for the 2D and 3D points are plotted and the distance between the points are calculated
5.0 CONCLUSIONThis program has been successfully coded, compiled and executed which has been very impressive and will go ahead to ease the extra work caused by plotting of graphs for simple calculations and it has demonstrated some reasonable programming logics like inheritance, polymorphism, and the use of objects which are very good OOP practices.