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
Question
Let’s Play with Numbers!!! Write the ComplexNumber class so that the following code generates the output below. class RealNumber: def __init__(self, r=0): self.__realValue = r def getRealValue(self): return self.__realValue def setRealValue(self, r): self.__realValue = r def __str__(self): return 'RealPart: '+str(self.getRealValue()) cn1 = ComplexNumber() print(cn1) print('---------') cn2 = ComplexNumber(5,7) print(cn2) OUTPUT: RealPart: 1.0 ImaginaryPart: 1.0 -------------------- RealPart: 5.0 ImaginaryPart: 7.0
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 3 steps with 1 images
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
- Modify the Car class example and add the following: A default constructor that initializes strings to “N/A” and numbers to zero. An overloaded constructor that takes in initial values to set your fields (6 parameters). accel() method: a void method that takes a double variable as a parameter and increases the speed of the car by that amount. brake() method: a void method that sets the speed to zero. To test your class, you will need to instantiate at least two different Car objects in the main method in the CarDemo class. Each of your objects should use a different constructor. For the object that uses the default constructor, you will need to invoke the mutator methods to assign values to your fields. Invoke the displayFeatures() method for both objects and display the variables. Demonstrate the use of the accessor method getColor() by accessing the color of each car and printing it to the console. Use the method accel to increase the speed of the first car by 65 mph. Use…arrow_forwardJava Help Please This is real please stop wasting time. Real Answer Please This questioned was answered in a wrong way several times someone else to answer it please Write a new class called DistanceFitnessTracker that extends FitnessTracker. DistanceFitnessTracker will represent a fitness tracker able torecord only distance. Here, you will not be asked to convert between distance units(Kilometers is the unit) Distance.java public class Distance {// Enum of distance unitspublic enum DistanceUnit {KILOMETRES,MILES}// Constantsprivate static final double KMS_PER_MILE = 1.609;private static final double MILES_PER_KM = 0.621;// Instance variablesprivate double value;private DistanceUnit distanceUnit;// Constructorspublic Distance(double value) {this.value = value;// Default unit is kmthis.distanceUnit = DistanceUnit.KILOMETRES;} public Distance(double value, DistanceUnit distanceUnit) {this.value = value;this.distanceUnit = distanceUnit;}// Methods: You should remove the comments and…arrow_forwardQ1: Write a complete JAVA program that carries out the following task s: Declare a class Video with the following non-static data members: v Vname (Type String). v my Price (Type int). The class also contains the following static data members. V number (Type int). daty The class also contains the following methods. V No_Argument_constructor to give initial values for all data members. V Full_constructor that accepts values of all data members as arguments from the user. V setName () method to reset the Vname of the Video. V getName () method to return the Vname of the Video. V set Price () method to reset the myPrice of the Video. V getPrice () method to return the my Price of the Video. V display () method that prints out the class data. V main () method to test the functionality of the class, asking the user to enter any necessary data. 3/r ado CS2301 - Homework2 Note: the static data member (number) is set to 0 and it is increment by 1 when an object is instantiated. Q2: What…arrow_forward
- write a python code Create the Testing class that does the following: a-Use the constructor to create an instance of Cylinder class cy with radius of 5 and height of 10. use the following code: class Circular_Shape_3D: radius = 0.0 #double value #Constructor def __init(self,radius): self.radius = radius #Get function def getRadius(self): return self.radius #Set function def setRadius(self, radius): self.radius = radius #Print function def Print(self): print("Circular_Shape_3D") print("Radius:", self.radius) class Cylinder(Circular_Shape_3D): #Radius value is already present in super class Circular_Shape_3D height = 0.0 #double value #Constructor def __init(self,radius,height): super().__init__(radius) self.height = height #Get function def getHeight(self): return self.height #Set function def setHeight(self, height): self.height = height…arrow_forwardJavaarrow_forwardIn Java Write a Fraction class that implements these methods:• add ─ This method receives a Fraction parameter and adds the parameter fraction to thecalling object fraction.• multiply ─ This method receives a Fraction parameter and multiplies the parameterfraction by the calling object fraction.• print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)• printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)• Separate accessor methods for each instance variable (numerator , denominator ) in theFraction classProvide a driver class (FractionDemo) that demonstrates this Fraction class. The driver class shouldcontain this main method : public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print(); System.out.println("Enter numerator; then denominator."); d = new…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