首页 > > 详细

c/c++编程代做、代写program程序

项目预算:   开发周期:  发布时间:   要求地区:
Department of Electrical Engineering and Electronics
Assignment Overview
Instantiation and manipulation of geometrical objects is significant in robotics. It is also
advantageous to be familiar with object-oriented programming features in C++. In this
assignment, you will design C++ classes capable of initialising polygons in a particular way,
and performing translations and rotations on them. This tests your ability to declare and define
classes and instantiate objects, using constructors, inheritance and polymorphism.
ELEC230 Robotic Systems
Assignment 1 – Object-Oriented Programming: Classes & Objects in C++
Module / Coursework ELEC230 / Assignment 1 – Classes & Objects in C++
Component weight 15%
Semester / HE Level 1 / 5
Lab location EEE PC Labs A402 & A406
Work Individual
Timetabled time C++ practice & advice are available in Weeks 4 – 7, totalling up to
15 hours although some time will be given to other topics. Lab
time includes time practising the C++ and OOP (Object-Oriented
Programming) exercises provided. You may ask questions about
the Assignment & relevant skills, and work on the Assignment
individually. You must write your own code & report, and
collusion, copying or plagiarism will be penalised.
Suggested private study ~10 hours – in addition to the timetabled time learning and
practising C++ and OOP.
Assessment method Individual, formal word-processed reports and .cpp files, as
described in the Marking Criteria.
Submission format Online via CANVAS using the template.
Please adhere to the template word and page limits.
Submission deadline 23:59 on Friday 10
th November 2023
Late submission Standard University penalties apply
Resit opportunity N/A
Marking policy Marked and moderated independently
Anonymous marking Yes
Feedback Via comments on CANVAS submission on-line
Learning outcomes (BH2) Understanding the features of an Object-Oriented
Programming language, and the ability to code in C++.
2
How much time did it
take YOU?
Let us know anonymously via https://bit.ly/EEECARES
Aspect
Marks
available
Indicative characteristics
Adequate / pass (40%) Very good / Excellent
Presentation
and
structure
10%
• Submission includes a Report, plus a
standalone .cpp file for each Part
attempted (one .cpp file each for Part A
and Part B). The latter are zipped while
the former is not.
• Report contains cover page
information (with Academic Integrity
declaration & Abstract), table of
contents, sections with appropriate
headings.
• Comprehensible language;
punctuation, grammar and
spelling are accurate.
• Equations, figures & tables are legible,
numbered and presented correctly.
• Excellent use of technical,
mathematic and academic
terminology and conventions.
• Word processed with consistent
formatting.
• Pages numbered, figures and
tables are captioned well.
• All sections clearly signposted.
• Excellent cross-referencing (of
figures, tables, equations) and
citations.
Introduction,
Method and
Design
40%
• Problem background is introduced
clearly
• Original code and comments
• Code is clearly laid out, easy to follow
and well- commented
• Design of each code segment follows a
logical sequence
• Design is adequately explained
• Excellent understanding of the
problem background is
displayed
• Code for each task is clean,
Don’t Repeat Yourself (in
programming), efficient and
elegant
• [Code is user-friendly if / when
relevant]
• Design is very well explained
Results 30% • Focused screenshots of program
output are presented for each task
• These include the printed output at
the terminal, and output in Desmos
and GeoGebra.
• Full-screen versions of each focused
screenshot are dumped in the
Appendix (in order of appearance in
the report). These must include the
full desktop including the taskbar
with date and time, and for the
terminal screenshots, they must also
include the IDE windows (e.g. editor
window showing program code).
• Screenshots correspond with code and
demonstrate at least partially correct
operation
• Screenshots, along with valid
code, clearly demonstrate
successful, correct output for
every task, in perfect
agreement with the
instructions and in the most
efficient way allowed by
them
• Printing to the terminal is
neat and comprehensible
(e.g. appropriate spaces, line
breaks, spelling, etc.) and
follows the exact form
instructed
• Screenshots are presented in a
coherent way that
corresponds well with the
logical flow of the report
3
Discussion 20% • Written discussion within each task
explaining each code segment. This
discussion is clearly original and shows
understanding of the relevant syntax
and semantics.
• This written discussion is in addition to
the code comments. It is accompanied
by snapshots of snippets of the code, to
illustrate the explanations.
• Discussion shows excellent
understanding.
• Coding decisions are justified.
e.g., rejected alternatives
explained.
• Some discussion of what might
be done to further enhance /
improve the program
ELEC 230 C++ & OOP Assignment 1 (2023-2024)
ProgramA (70%):
1. Write a class called polygon which can initialise regular1 Two-Dimensional (2D) polygons, and
translate them in the +/-x and +/-y directions (or both x and y). It should also be able to rotate
them by any number of degrees about any point. Come up with your own names for all class
members except N and r. The following members must be included in your class, exactly as
instructed, and must serve a meaningful purpose in your program:
• Private members:
o Member of type std::string, to store a ‘user’-defined polygon name (e.g. “t_1”)
• Note: the ‘user’-defined polygon name must always take the form l_i where
l is a letter, i an integer; this also applies in ProgramB.
o Member (r) of type double, to store the radius.
o Member (N) of type integer, to store the number of vertices.
o Member of type std::vector, to store the x-coordinates of the polygon vertices.
o Member of type std::vector, to store the y-coordinates of the polygon vertices.
o Member function which prints any object’s name, number of vertices and coordinates
(as a coordinate pair for each vertex) on screen using the standard output stream. The
printed output must take the following exact form (although obviously the ‘user’
defined polygon name, the coordinates and the number of coordinate pairs will vary).
All numerical printed output should be rounded to 5 decimal places:
t_1=polygon((1.73205,-1),(0,2),(-1.73205,-1))
• Public members:
o Constructor function which, firstly, accepts and stores the name, r and N. Secondly, it
then uses this data to initialise and store the coordinates of the polygon vertices. When
initialised, each polygon must be centred on the origin (0,0), and its base must be
horizontal (parallel with the x axis). o Member function to translate any object, and
efficiently print the object name and coordinates before and after translation, and the
translation vector applied, in the following exact form:
Before translation: t_1=polygon((1.73205,-
1),(0,2),(-1.73205,-1)) After translation by
[-4,0]:
t_1=polygon((-2.26795,-1),(-4,2),(-5.73205,-1))
o Member function to rotate an object of this class about any point, and efficiently print
the object name and coordinates before and after rotation; also, how many degrees of
rotation were applied and from what point the rotation was around. (Positive rotation
is anticlockwise.) In the following exact form:
Before rotation:
t_1=polygon((1.73205,-1),(0,2),(-1.73205,-1))
After rotation 90 degrees anticlockwise about (1,2):
t_1=polygon((4,2.73205),(1,1),(4,-0.73205))
1
‘Regular’ means that all the polygon’s internal angles are the same, and all edges are of identical length.
4
o The word ‘efficiently’ underlined twice above implies that there are opportunities here
to avoid repeating code (DRY). Can you work out how?
2. Write a program incorporating the above class in the global scope. In your ‘main’ function,
instantiate a triangle, a square and an 𝑛-gon (you choose 𝑛 > 4) using your constructor function
created above. For each polygon, following instantiation, call sequentially first the translation,
then the rotation function. Rotation must be by 90o about (a,b) and translation by (a,-b), where
a and b are the final two non-zero digits in your student ID. For each stage, (instantiation,
rotation and translation) copy and paste the relevant terminal output into
https://www.desmos.com/calculator to generate an image of a polygon, and include screenshots
of both the terminal output and the Desmos polygon in your report, as evidence of your working
program (see also Marking Criteria).
5
ProgramB (30%):
Write a second program2 by following the steps below:
1) Copy and alter your class “polygon” to create a new class3
, “polygon3d”, that can initialise,
store and print any shape – regular or irregular – in Three-Dimensional (3D) space. Get rid of the
member variable for radius, which is no longer meaningful, and alter the constructor function so that it
now directly accepts and store the coordinates of the vertices. Delete N too. Don’t make other changes
yet.
2) Rotation and translation need not be defined in polygon3d. Therefore, turn the functions for
translation and rotation into pure virtual members, making polygon3d into an abstract base class.
Convert the private members of polygon3d into ‘protected’ members to allow a layer of inheritance.
3) Create three new classes publicly inherited from polygon3d, called polygon_xy, polygon_xz
and polygon_yz. Each class must only be able to perform rotations and translations in its own active
set of planes (defined by xy, xz or yz). You should achieve this by overriding polygon3d’s translation /
rotation functions in each inherited class.
• E.g. objects of the polygon_xy class can be translated by (1,2,0) but not by (1,2,5), since this would involve
an alteration of the z-coordinates i.e. ‘movement’ in a plane other than an xy plane.
• E.g. objects of the polygon_xy class can only be rotated in an xy plane – again, z-coordinates can’t be
altered by rotations, since this would entail ‘movement’ in a plane other than an xy plane.
• Similar rules apply for polygon_xz and polygon_yz in accordance with the planes given in their names.
See the ‘Assignment 1 Support’ folder (which will be updated periodically) for help with constructor
inheritance.
Important: the format of your efficient printed output to terminal should now be changed slightly so
that the line containing name and coordinates looks like the following exact form (for example):
t_1=Polygon({(0,0,0),(2,1,3),(1,3,4)})
In a similar way to ProgramA, create a program, instantiate one object of each class, and apply a
translation and a rotation sequentially to each object. This time, choose your own (non-zero) rotation
and translation coordinates. Test and produce evidence for your report in
https://www.geogebra.org/calculator using the ‘3D Calculator’ option (in a similar way as before with
Desmos), and with terminal output screenshots.
Now choose either Task 4 or Task 5 (Not both):
4) For one of the above inherited classes, add a public member function which overloads the +
operator to add one triangle’s coordinates to another’s in a single operation. You should be able to code
“object3 = object1 + object2” with the result that the coordinates of object3’s vertices in each dimension
become a sum of those of object1 and object2. E.g.:
0
o object1 vertex coordinates: (1,2,5), (2,8,5), (4,1,5)
o object2 vertex coordinates: (2,4,6), (3,5,8), (2,1,8)
o  object3 vertex coordinates become: (3,6,11), (5,13,13), (6,2,13)
2 Save your original program (ProgramA) as a .cpp file. Then, simply copy the code for class “polygon” into a new
.cpp file, rename the class “polygon3d” and modify it according to the instructions.
6
Your function should also be able to efficiently achieve printing of information about the operation,
and object details before/after it, just as with the rotation/translation functions above & in ProgramA.
In your ‘main’, instantiate some triangular objects & call this function to demonstrate its operation.
Provide appropriate evidence of this with screenshots of GeoGebra and terminal output.
5) Alternatively, in your ‘main’ function, instantiate 3 objects, each of a different inherited class
from (3). Then, by using an array of base class pointers, pointing to objects of the derived classes in
question (3), write code in your ‘main’ function to batch-translate the objects of the different derived
classes, with a single for-loop. Translations should be non-zero in the appropriate plane for each object.
(Again, choose your own translation vectors). You will utilise pre-existing functions – so, just as above
and in ProgramA, details of the individual operations and starting/finishing object details should be
efficiently printed as part of the process. Provide appropriate evidence of the batch translation with
screenshots of Desmos or Geogebra and terminal output, as before.
Notes for BOTH Parts A and B:
• All objects should be stored in the code (e.g. creating a new object of class polygon should
not have to involve deleting a previous object of this class.)
• You should find that the transformations performed by your member functions actually
alter the stored object’s attributes. So, for example, if a translation is followed by a rotation
on the same object, the coordinates passed into the rotation are the new coordinates
following the translation. (This is a requirement of the Assignment.)
• Don’t try to interface with the ‘user’ – there is no need to issue messages to the user
inviting them to enter input, etc. When instantiating or manipulating objects, just hardcode
these actions into your main function, on behalf of the ‘user’. Similarly, don’t try to create
a menu-driven program!
Important Further Hints and Notes:
1. In this particular assignment, it isn’t the destination – it’s the journey. This means that in this
assignment, the learning objectives in respect of C++ and OOP are met by following the design
instructions closely, paying particular attention to object-oriented-programming and code
efficiency where possible/relevant, and not worrying too much about (perceived) usefulness of
the resulting programs. Don’t try and shortcut the assignment instructions!
2. Refer to the ‘Assignment 1 Support’ folder – and keep referring back, as it will be periodically
updated (it may not contain much when you first look there.)
3. When it comes to writing your report, use the Submission Template which will be added to the
above folder in due course.
4. I would like to emphasise something already mentioned: DO NOT try and invite a ‘user’ to
instantiate or manipulate objects at runtime – just instantiate/manipulate ‘directly’ (on behalf of
the ‘user’, if you will) within the code of your ‘main’ function. So there will not be any call and
response at the terminal – when your programs are run, they will simply generate a bunch of
output according to what instructions you have given in the main function.
5. To initialise each polygon in Part A, you will need to first set its coordinates using N and r, then
rotate it about the origin by some amount so that the base lies ‘horizontal’.
6. Rotational matrix equation for 2D rotation of a single coordinate point, where 𝑥, 𝑦 are the
starting coordinates, 𝑥′, 𝑦′ are the coordinates after rotation, and 𝐴 is the angle of rotation about
the origin:
7
x' = x * cos(θ) - y * sin(θ)
y' = x * sin(θ) + y * cos(θ)
7. For the rotation function, you may find that you want to create a copy of your object. Note,
firstly, that the ‘=’ operator will automatically invoke the default copy constructor
(Without you needing to write a copy constructor). But what to make it equal to? That’s
where the ‘this’ keyword could come in handy. ‘this’ is a keyword which refers to the
current object. Since ‘this’ is actually a pointer, dereference it (*this) and make your
dummy/copy object equal to it.
8. If in doubt, assume within reason that the same rules about functionality and output apply for
ProgramB as ProgramA unless instructed differently. If still unsure, ask!
9. Read the Marking Criteria on Page 2 of this Assignment brief and take a look at the Assignment
1 Discussion Board on Canvas – even if you don’t have any questions, the answers to questions
there might reveal misconceptions you didn’t know you had.
Note: In the Robot Operating System (ROS), 3D rotations are achieved with quaternions. Although this
Assignment does not ask you to perform full 3D rotations or use quaternions, you can read more about
them here.
What to submit
1. Commented standalone code for each program, should be formatted and added to the report.
2. A Report as a pdf:
• Your Report should strictly follow the template provided sticking to page and word limits.
o Screenshots for each task, showing (a) the program output at the terminal and (b) the
corresponding polygons generated in Desmos or GeoGebra. (These should, of course, be
presented as figures with figure numbers and captions and annotation if required. Feel
free to combine the polygons on 1 graph)
o A discussion of each program’s design and results, showing your understanding of your
own code and of C++ features used. You can enhance this with snapshots or snippets of
your code,
• Your Report should also an Appendix with full-screen screenshots as instructed in the
Marking Criteria, p.2, in the same order of appearance as in the main body of the report.
• Follow also all the other instructions in the Marking Criteria, p.2.
Warning
When marking your reports, we will be looking very closely for any signs of collusion, as this is unacceptable.
We want to assess your own ability, not that of your friend or colleague. If we find any evidence of collusion or
copying then the formal University rules will be followed which may result in your suspension. Similarly, your
code, comments and discussion must be your own and not taken from any other source (e.g. online.) If we find
evidence that part(s) of your work is/are copied or closely paraphrased from any source then the formal University
rules will be followed on plagiarism and collusion, which may result in your suspension or termination of studies.
Submission information / deadline
Submit an Electronic copy to CANVAS by: 23:59 on Friday 10
th November 2023.

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!