From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- C++/Inheritance/INSTRUCTIONS | 35 ++++++++++++++ C++/Inheritance/Inheritance.cpp | 102 ++++++++++++++++++++++++++++++++++++++++ C++/Inheritance/person.h | 12 +++++ 3 files changed, 149 insertions(+) create mode 100644 C++/Inheritance/INSTRUCTIONS create mode 100644 C++/Inheritance/Inheritance.cpp create mode 100644 C++/Inheritance/person.h (limited to 'C++/Inheritance') diff --git a/C++/Inheritance/INSTRUCTIONS b/C++/Inheritance/INSTRUCTIONS new file mode 100644 index 0000000..8dfab17 --- /dev/null +++ b/C++/Inheritance/INSTRUCTIONS @@ -0,0 +1,35 @@ + +Project 8: Inheritance +Due: Monday, October 31st, 2022 before midnight +100 Points +Write a program that does the following: +1. Make a parent class called person with the following variables: first name, last name, street address, city, state, zip, phone number +2. Make a child class called student that inherits from person. This class will have the following variables: GPA, major, credit hours, anticipated year of graduation +3. Move the parent class to a header file and include it into your main program +4. Get data for all of the above variables (keyboard or input file. Your choice) +5. When the user is finished updating information, output everything to the screen +Assignment Notes: + + Make variables either arrays or vectors - your choice + I expect to see functions throughout this program + +General Notes: +Be sure to use comments in your program: Name, Program Description, Date and anywhere else in the program you deem necessary. +If you are stuck, I will help you! +Grading Rubric: + + If you do not include comments at the top of the program (name, program description, date), you will lose 15 points + If your program is not object-oriented, you will receive a 0/100 (OOP is requred for this assignment) + If your program does not use functions, you will lose up to 75 points (depending on the number of functions missing) + If your program does not compile (run), then I will give a grade of 0/100. But will give you the change to repair for points back (some points are better than none) + If your program is late (within 48 hours of the due date), you will lose 25 points + If your program is late beyond the 48 hour due date, I will typically still accept it, but you will lose far more points. Depends on when you turn it in + If you use global variables in your program, I will deduct 5 points for each used + If your program is not formatted nicely (code all over the place, ugly), you will lose up to 25 points depending on the extent + If your program stops working when I run it, you will lose points. The exact amount depends on the severity of the error + If your program still has your friend's name on it, I will send you a message asking you to try harder while giving you a 0/100 + If you submit a file type I cannot open, such as .sln, you will receive a 0/100. You will be able to resubmit for credit, but you will lose up to 90 points (depending on how late it is) + If your program looks like a a professional programmer wrote it, I will write to you to ask if you want a job. Well, maybe not. But, I will ask about the code + This is just a list of typical issues I run into when grading to give you some idea of where your points go. Points can be taken off for other reasons. + + diff --git a/C++/Inheritance/Inheritance.cpp b/C++/Inheritance/Inheritance.cpp new file mode 100644 index 0000000..3d022b4 --- /dev/null +++ b/C++/Inheritance/Inheritance.cpp @@ -0,0 +1,102 @@ +// Name: msglm +// Date: Oct-31st-2022 +// Program Name: Inheritance +// Description: Inheritance practice + +#include +#include +#include +#include "person.h" +using namespace std; + + +//Classes +//I love it when my "cat" object can do my taxes because some incompetent intern in upstream decided to +//that the great-great-great-great-great-great-grandparent "basic" object needs that functionality +// +//I also love it when i'm programming and everything must be an object, thus making me have to inherit from 40 million parents who supply their own +//lovely genetic debt and confusion, just to do something simple (Godot and Java both do this and it makes me rage). +// +//OOP is one of those things that's entire purpose, code reuse, is annhiliated by itself once you try to use it and can be replaced by tech we had before. Any time I have the dismay of using an OOPy system, I have to reimplement half the things offered with my own implementations because the junk that's offered is burried under so much inherited cruft that it's outright impossible to use them without breaking a couple keyboards. +//Code reuse is also misnomer, people really mean "functionality reuse", which can be achieved with a mix of good data structure design and subroutines, tech that has existed since the days of the ENIAC (and theoretically from the days of Turing). +// +//Inheritance alone makes using GOTO calls feel like some revolutionary technology that made the lives of all developers easier. +class student: public person { + public: + float GPA; + string major; + int hours; + int yearOfGrad; +}; + + +//Takes in the initalized file and puts it into an object instance +student getStudent() { + student student; + string temp; + + cout << "===Enter your information===\n"; + cout << "Please enter your first name: "; + cin >> temp; + student.fname = temp; + cout << "Please enter your last name: "; + cin >> temp; + student.lname = temp; + cout << "Please enter your address: "; + cin >> temp; + student.address = temp; + cout << "Please enter your city: "; + cin >> temp; + student.city = temp; + cout << "Please enter your state: "; + cin >> temp; + student.state = temp; + cout << "Please enter your major: "; + cin >> temp; + student.major = temp; + cout << "Please enter your zip code: "; + cin >> temp; + student.zip = stoi(temp); + cout << "Please enter your phone number: "; + cin >> temp; + student.phonenum = stoi(temp); + cout << "Please enter your GPA: "; + cin >> temp; + student.GPA = stoi(temp); + cout << "Please enter your hours: "; + cin >> temp; + student.hours = stoi(temp); + cout << "Please enter your year of graduation: "; + cin >> temp; + student.yearOfGrad = stoi(temp); + return student; +} + +void out(student student) { + cout << "fname: " << student.fname << endl; + cout << "lname: " << student.lname << endl; + cout << "address: " << student.address << endl; + cout << "city: " << student.city << endl; + cout << "state: " << student.state << endl; + cout << "zip: " << student.zip << endl; + cout << "phonenum: " << student.phonenum << endl; + cout << "GPA: " << student.GPA << endl; + cout << "major: " << student.major << endl; + cout << "hours: " << student.hours << endl; + cout << "yearOfGrad: " << student.yearOfGrad << endl; + +} + + +int main() { + + out(getStudent()); +} + +/* + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3 ONLY as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ diff --git a/C++/Inheritance/person.h b/C++/Inheritance/person.h new file mode 100644 index 0000000..a9fca01 --- /dev/null +++ b/C++/Inheritance/person.h @@ -0,0 +1,12 @@ +#include +using namespace std; +class person { + public: + string fname; + string lname; + string address; + string city; + string state; + int zip; + int phonenum; +}; -- cgit v1.2.3