
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
thumb_up100%
Create a class named Line:
(a) Define private data members p1 and p2 as pointer to Point objects (the
one we had in lectures), slope and length as double variables.
(b) Define setter and getter functions.
(c) Define a null-constructor that initializes numeric variables with zero and
allocate dynamic memory for points and initialize them to [0,0] as well.
(d) Overload a constructor that allocates memory for points, initilize them
with given arguments, and calculate the slope and length.
(e) Implement destructor, copy constructor and copy assignment operator.
(f) Create a function called ”parallel” that takes too Line objects, returns
true when given lines are parallel and returns false otherwise.
(g) Overload the less than (<) and greater than (>) and equality (==) operators (compare the length).
(h) Write a functions that reads lines in the format provided in the lines.txt
from the file (without any change) and stores them in a vector named Lines.
(i) Sort the objects of Lines vector in ascending order using the sort function from algorithm library.
(j) Extend the functionality of cin and cout for this class. For cin function
you need to define a template like [(x1,y1,),(x2,y2)], and ask user to enter
the entire input at once. Then you will parse the input, extract x1, y1,
x2, and y2 and create an object of Line with them.
Need help with (j) immedietly. Thanks.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a C#program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string) ClassRegistration -…arrow_forwardin C++ Define a new “Word” class that must inherit from the given Name class. This class manages a dictionary word info: name (string) and its definition (string). It must prevent the creation of a Word object with either an empty or all-blank word or definition. This class must at least complete the methods defined in the Name class: toString method returns a string representation of the Word object in the format of “WORD( <word> ) DEFINITION( <definition> ) such as WORD(school) DEFINITION(an educational institution) contains method that accepts a search string and returns true if either word or definition contains the search string as a substring. It returns false otherwise. isTheSame method that compares two Word objects and returns true only if both Word objects have the exact same word and definition and false otherwise. Please note that if the given object in the parameter is not a Word object, it will return false.arrow_forwarddemonstrates the entire anagram.cpp application. Assign the phrase to be anagrammed a title. The class's member methods enable the rotation, anagram, and presentation of the word. The user-supplied word is obtained by the main() procedure, which then uses the anagram() member function to anagram the word after creating a word object with the user-supplied word as an input to the function Object() { [native code] }.arrow_forward
- Implement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forwardInstructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…arrow_forwardDefine a class named IDProtected Data Member: number - type int pointer (dynamic variable)number has to be 10 digits integer.Appropriate accessor and mutator functions.Default constructor and one argument constructor.Overload the insertion operator << to output ID objects.Overload the extraction operator >> to input ID objects.Add big three to ID class.Please indicate call of big three. Use following main() to test your class.int main(){ ID a(12345678); cout<<a; ID b = a; cin>>a; cout<<a; ID c; c = a; cin>>a; cout<<a; cout<<b; cout<<c;} Output from given main function:ID number: 12345678ID => copy constrcutor is calledEnter id number: 1234ID number: 1234ID => Assignment operator is calledEnter id number: 56789ID number: 56789ID number: 12345678ID number: 1234ID => Destructor is calledID => Destructor is calledID => Destructor is calledarrow_forward
- File Upload 3.5 Hide Answer Define a class "Point" with two instance variables-x and y, representing the Cartesian coordinates of the point. The class should contain a default constructor which initializes a point in the origin and a parameterized constructor which initializes a user-specified point. Create another class "Line" that inherits Point class. The class should include the instance member- a reference variable of Point class. The constructor of Line class, should create a new Point object to denote the end point of the line. The starting point of the line is automatically created when it extends the Point class. The Line class also should include calculateDistance() method to find the length of the line, thus created. Note: distance=v((x2- X1)" + (y2- y1)) Write a main class that tests the above inherited class for an array of objects. Uploaded File Details c09380d8-09b5-33ab-b418-af651ba20094.pdf Evaluated Version + Previous Page: 1/2 Next > + Previous Page: 1/2 Next > Zoom:…arrow_forwardDefine a default constructor that initializes the data members, string title and integer year, with the default values "Empty" and -1, respectively. Ex: If the input is Magnolia 1989, then the output is: Title: Empty, Year: -1 Title: Magnolia, Year: 1989 Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters. 5 class Book { 6 public: 7 8 9 10 11 12 13 14 15 }; 16 Book(); void SetTitle(string bookTitle); void Set Year (int bookYear); void Print (); private: string title; int year; 17 Your code goes here */ 18 19 void Book::SetTitle(string hook Title) { CS Scarint (19 bi Title mscanner 22 23 void Book Set Year(int bookYear) [ 2arrow_forwardThe base class Pet has protected data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function. Ex. If the input is: Dobby2Kreacher3German Schnauzer the output is: Pet Information: Name: Dobby Age: 2Pet Information: Name: Kreacher Age: 3 Breed: German Schnauzer #include <iostream>#include<string>#include "Dog.h" using namespace std; int main() { string petName, dogName, dogBreed; int petAge, dogAge; Pet myPet; Dog myDog; getline(cin, petName); cin >> petAge; cin.ignore(); getline(cin, dogName); cin >> dogAge; cin.ignore(); getline(cin, dogBreed); // TODO: Create generic pet (using petName, petAge) and then call PrintInfo //…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education