Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
cpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edu
cpp
Commits
62d60730
Commit
62d60730
authored
Dec 17, 2020
by
Hans Buchmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Point all public very bad
parent
a5cde559
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
16 deletions
+78
-16
6-cia/src/geo2d-vz.cc
6-cia/src/geo2d-vz.cc
+78
-16
No files found.
6-cia/src/geo2d-vz.cc
View file @
62d60730
...
...
@@ -6,6 +6,62 @@
#include <cmath>
#include <fstream>
//---------------------------- class SVG
class
SVG
//Singleton
{
public:
static
void
line
(
double
x0
,
double
y0
,
double
x1
,
double
y1
);
static
void
dot
(
double
x0
,
double
y0
,
double
r
=
3
);
// |default radius
private:
static
SVG
svg
;
// the Singleton declared
static
const
char
File
[];
std
::
ofstream
out
;
SVG
();
~
SVG
();
};
//------------------- implementation SVG(
const
char
SVG
::
File
[]
=
"geo2d.svg"
;
SVG
SVG
::
svg
;
//constructor defined and initialized
SVG
::
SVG
()
:
out
(
File
)
{
out
<<
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
no
\"
?>
\n
"
"<!DOCTYPE svg PUBLIC
\"
-//W3C//DTD SVG 1.0//EN
\"\n
"
"
\"
http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd
\"
>
\n
"
"<svg xmlns=
\"
http://www.w3.org/2000/svg
\"\n
"
" xmlns:xlink=
\"
http://www.w3.org/1999/xlink
\"
>
\n
"
"<g stroke=
\"
black
\"
>
\n
"
;
}
SVG
::~
SVG
()
{
std
::
cout
<<
"figure in file '"
<<
File
<<
"'
\n
"
;
out
<<
"
\n
</g>
\n
"
"</svg>
\n
"
;
}
void
SVG
::
line
(
double
x0
,
double
y0
,
double
x1
,
double
y1
)
{
svg
.
out
<<
"<line x1=
\"
"
<<
x0
<<
"
\"
"
"y1=
\"
"
<<
y0
<<
"
\"
"
"x2=
\"
"
<<
x1
<<
"
\"
"
"y2=
\"
"
<<
y1
<<
"
\"
/>
\n
"
;
}
void
SVG
::
dot
(
double
x0
,
double
y0
,
double
r
)
{
svg
.
out
<<
"<circle cx=
\"
"
<<
x0
<<
"
\"
"
"cy=
\"
"
<<
y0
<<
"
\"
"
"r=
\"
"
<<
r
<<
"
\"
/>
\n
"
;
}
//------------------- implementation SVG)
//---------------------------------------------- Point
// declaration
class
Point
...
...
@@ -20,9 +76,10 @@ class Point
//other cannot be changed
static
double
distance
(
Point
p
,
Point
q
);
private:
double
xc
;
//x-coordinate
double
yc
;
//y-coordinate
// private: Suende
void
svg
();
//draw the point
double
xc
;
//x-coordinate
double
yc
;
//y-coordinate
};
//----------------------------------------------- Line
...
...
@@ -34,6 +91,7 @@ class Line
// |--------------|-------------- by C++ reference
~
Line
();
private:
void
svg
();
//draw the line
Point
pp
;
//by value
Point
qq
;
//by value
};
...
...
@@ -45,7 +103,7 @@ Point::Point(double x,double y) //x,y parameter
:
xc
(
x
),
yc
(
y
)
//init list:only for construtors
//xc=x,yc=y
{
s
td
::
cout
<<
"constructor of Point "
<<
xc
<<
","
<<
yc
<<
"
\n
"
;
s
vg
()
;
}
Point
::
Point
(
const
Point
&
other
)
...
...
@@ -59,6 +117,12 @@ Point::~Point()
std
::
cout
<<
"destructor of Point "
<<
xc
<<
","
<<
yc
<<
"
\n
"
;
}
void
Point
::
svg
()
{
// SVG::dot(xc,yc,3);
SVG
::
dot
(
xc
,
yc
);
//with default radius
}
double
Point
::
distance
(
Point
p
,
Point
q
)
//is not a member of Point
{
return
std
::
hypot
(
q
.
xc
-
p
.
xc
,
q
.
yc
-
p
.
yc
);
...
...
@@ -85,7 +149,7 @@ double Point::distance(const Point& other) const //is a member of Point
Line
::
Line
(
const
Point
&
p
,
const
Point
&
q
)
:
pp
(
p
),
qq
(
q
)
//copy constructor p->pp and copy constructo q->qq
{
s
td
::
cout
<<
"constructor Line
\n
"
;
s
vg
()
;
}
Line
::~
Line
()
...
...
@@ -93,18 +157,16 @@ Line::~Line()
std
::
cout
<<
"destructor Line
\n
"
;
}
void
Line
::
svg
()
{
SVG
::
line
(
pp
.
xc
,
pp
.
yc
,
//x0,y0
qq
.
xc
,
qq
.
yc
);
//x1 y1
}
int
main
(
int
argc
,
char
**
args
)
{
Point
p
(
3
,
4
);
//constructor of Point 3,4
Point
q
(
6
,
8
);
//constructor of Point 6,8
/*
copy constructor of Point 3,4 see pp by value
copy constructor of Point 6,8 see qq by value
*/
Point
p
(
150
,
200
);
//constructor of Point 3,4
Point
q
(
300
,
400
);
//constructor of Point 6,8
Line
l
(
p
,
q
);
//constructor Line
return
0
;
}
//destructor Line
// destructor of Point 3,4
// destructor of Point 6,8
//destructor of Point 6,8
//destructor of Point 3,4
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment