haas/spring2026/cprog/projects/oop0.md
... ...
@@ -0,0 +1,189 @@
1
+# CSCS1320 C/C++ Programming
2
+
3
+# PROJECT: OBJECT-ORIENTED PROGRAMMING (oop0)
4
+
5
+## OBJECTIVE
6
+
7
+Explore the basics of C++ programming, specifically the creation of
8
+classes and instantiation of objects, and the implementation of a simple
9
+program that has and uses a class.
10
+
11
+The idea is to demonstrate your skills gained throughout the semester, by
12
+harnessing new concepts and problem solving experiences to delve into
13
+this new area of the course: C++ and object-oriented programming.
14
+
15
+## C++
16
+
17
+### BACKSTORY
18
+
19
+In the 1960s-1990s many computer programming languages were being created
20
+for different purposes, but most of them had flaws. Some languages were
21
+easy to understand, but lacked the depth to accomplish more difficult
22
+tasks. Others had this capability, but were large, abstract, and very
23
+difficult to learn, thus leading people to create more with the goal of
24
+having a language that was not too complex, but could effectively
25
+complete difficult tasks. This eventually led to a C language that was
26
+good for low level programming, and a SIMULA language that had a class
27
+system. C++ language was the creation of Bjarne Stroustrup that combined
28
+these two.
29
+
30
+The main difference between the two is that C is a procedural programming
31
+language, whereas C++ is a hybrid language that can perform both
32
+procedural and object-oriented programming. C supports built in data
33
+types, whereas C++ can support both built-in and user defined data types.
34
+C has 32 keywords, whereas C++ has 63 keywords, and C++ supports far more
35
+things in general than C. From a security standpoint, C does not support
36
+encapsulation so data can be manipulated by outside code meanwhile C++
37
+supports encapsulation so the data is hidden.
38
+
39
+C++ is still updated today because it is still so widely used today, due
40
+to its speed, programming capability, and its continued popularity in
41
+being used (even if a superior language did come out computer scientists
42
+would still have to learn that new language, and languages already
43
+written in C++ would still be written in C++).
44
+
45
+C++ is most notably used in the creation of high performance programs,
46
+such as video games, operating systems, and the Google Chrome and Firefox
47
+web browsers.
48
+
49
+C++ is a play on the ++ increment operator in C language.
50
+
51
+C++ was originally called 'The New C'.
52
+
53
+C++ has influenced other programming languages such as C# and Java.
54
+
55
+### OOP
56
+
57
+Object Oriented Programming refers to a type of programming that uses
58
+objects that contain both data and functions. This is opposed to
59
+procedural programming, which is about writing procedures or functions
60
+that perform operations. OOP has several advantages over Procedural
61
+Programming which include:
62
+
63
+ * OOP provides a management structure for programs.
64
+ * OOP helps make code easier to maintain, modify and debug.
65
+ * OOP makes it possible to create reusable applications with less code and a shorter development time.
66
+
67
+## CLASSES
68
+
69
+Classes are effectively user defined data types. They make it easier
70
+to work with data by providing users with the ability to create
71
+constructors, destructors, member data, member functions, and more.
72
+
73
+In C++, you can define data inside of classes for the sake of using them
74
+with member functions. Access specifiers can be used to determine where
75
+these variables can be called from, and which functions can call them.
76
+(This is further described down below)
77
+
78
+Methods are functions that belong to a class. The two ways to define a
79
+function that belongs to a class are inside the class definition and
80
+outside the class definition. In order to define a method outside the
81
+class definition, you must first declare it inside the class. You can
82
+then define your function outside of the class by specifying the name of
83
+the class and following it with the "::" operator. These functions are
84
+meant to be used alongside member data.
85
+
86
+Constructors are functions that are called when an object is created.
87
+They can be used with or without parameters, similarly to any other type
88
+of function. They do not return any values.
89
+
90
+Destructors are special functions that are called in any of the below
91
+conditions:
92
+
93
+ * the function ends
94
+ * the program ends
95
+ * a block containing local variables ends
96
+ * a delete operator is called
97
+
98
+They are meant to be used when a pointer is used in a class, or when
99
+memory has been dynamically allocated, in order to prevent memory
100
+leakage.
101
+
102
+C++ classes are by default value types. Value types typically deal with
103
+memory or layout control, whereas, reference types are related to base
104
+classes and virtual functions for polymorphic purposes. A difference
105
+between the two types, is that value types are copyable, meaning, there
106
+is a copy constructor and copy assignment operator. Reference types on
107
+the other hand, make the class non-copyable, using a virtual destructor.
108
+Changing the class type is something that is done by the user/programmer,
109
+and is done by disabling the copy constructor and copy assignment
110
+operator. In short value types are about creating two values that can
111
+each be modified, whereas, reference types are more about identity.
112
+
113
+### ACCESS CONTROL
114
+
115
+Public members can be accessed in any part of the program.
116
+
117
+Private members can only be accessed by members of the same class.
118
+
119
+Protected members can be accessed by members of the same class, friend
120
+classes, and derived classes.
121
+
122
+Struct members are public by default.
123
+
124
+Class members are private by default.
125
+
126
+## INHERITANCE
127
+
128
+Single inheritance is when one class inherits directly from one other
129
+class. This is typical for most classes. Public inheritance does not
130
+change in subclasses from the parent class. Protected inheritance refers
131
+to when anything higher than protected will be protected. Both public and
132
+protected properties will be protected in a subclass. Private inheritance
133
+takes this a step further as all three inheritance types will be made
134
+private in a subclass.
135
+
136
+### OBJECTS
137
+
138
+Instances of a class. Creating an object of a class works almost exactly
139
+like initializing any fundamental type; simply specify the the type name,
140
+followed by your variable's name. Objects are introduced by declarations.
141
+
142
+## PROGRAM
143
+
144
+Write a program that:
145
+
146
+ * creates one or more classes.
147
+ * That contains, in addition to at least 2 constructors (parameterless, and a parametered), various supporting member functions
148
+ * utilizes access control, and makes use of private member data
149
+
150
+Have a main() function that instantiates an instance of your chosen
151
+class, and runs that instantiated object through a range of tests
152
+demonstrating the class works as intended (likely also prompting the user
153
+to input values to configure the attributes of the object).
154
+
155
+Compile the program with the `g++` compiler (it uses many of the same
156
+basic arguments as `gcc`)
157
+
158
+## REFERENCES
159
+
160
+ * https://www.learncpp.com/cpp-tutorial/public-vs-private-access-specifiers/
161
+ * https://www.learncpp.com/cpp-tutorial/classes-and-class-members/\
162
+ * https://www.w3schools.com/cpp/cpp_classes.asp
163
+ * https://www.w3schools.com/cpp/cpp_constructors.asp
164
+ * https://www.geeksforgeeks.org/destructors-c/
165
+ * https://docs.microsoft.com/en-us/cpp/cpp/value-types-modern-cpp?view=msvc-160
166
+ * https://ofstack.com/C++/9644/example-analysis-of-access-control-in-c++-inheritance.html
167
+ * https://www.w3schools.com/cpp/cpp_oop.asp
168
+ * https://www.w3schools.com/cpp/cpp_class_methods.asp
169
+ * https://www.geekboots.com/story/10-interesting-stories-about-c
170
+ * https://www.tutorialspoint.com/difference-between-c-and-cplusplus
171
+
172
+## SUBMISSION
173
+
174
+I'll be looking for the following:
175
+
176
+```
177
+312:oop0:final tally of results (312/312)
178
+*:oop0:no compiler messages, program compiles and runs without issue [62/62]
179
+*:oop0:specified functionality is implemented [62/62]
180
+*:oop0:utilizes classes [64/64]
181
+*:oop0:utilizes access control, including private member data [64/64]
182
+*:oop0:demonstrates use of Object Oriented Programming [62/62]
183
+```
184
+
185
+Additionally:
186
+ * Solutions not abiding by **SPIRIT** of project will be subject to a 50% overall deduction
187
+ * Solutions not utilizing descriptive why and how **COMMENTS** will be subject to a 50% overall deduction
188
+ * Solutions not utilizing **INDENTATION** to promote scope and clarity will be subject to a 50% overall deduction
189
+ * Solutions lacking **ORGANIZATION** and are not easy to read (within 90 char width) are subject to a 50% overall deduction