
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

Transcribed Image Text:**Task: Creating a Python Class for a Clock**
**Objective:** Write a Python class named `Clock` that incorporates the following elements:
1. **Instance Variables (Attributes):**
- `year`
- `month`
- `day`
- `hour`
- `minute`
- `second`
2. **Constructor:**
- Initialize the date to today’s date
- Set the time to `00:00:00`
3. **Methods:**
- Provide two methods for each instance variable:
- A method to get the current value of the variable
- A method to set a new value for the variable
- Ensure the values are set using the time and date methods specified in the "Resources" section on D2L (Desire2Learn).
**Implementation Requirement:**
- Develop a test program (main program) to instantiate a `Clock` object and validate all the implemented methods.
**Note:** The test program should verify the functionality by calling each method and ensuring the `Clock` object behaves as expected.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
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
- Write the DECLARATION of a class movie as follows: (HINT: you must INCLUDE this in another file) Data member variables: title, star, year released Methods: default constructor and constructor with parameters to set all variables, print, set year, set star, set title. Be sure to include any necessary include and using directives. Include any directives that will prevent compilation errors due to multiple inclusions of a header filearrow_forwardIn python and include doctring: First, write a class named Movie that has four data members: title, genre, director, and year. It should have: an init method that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings. get methods for each of the data members (get_title, get_genre, get_director, and get_year). Next write a class named StreamingService that has two data members: name and catalog. the catalog is a dictionary of Movies, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have: an init method that takes the name as an argument, and assigns it to the name data member. The catalog data member should be initialized to an empty dictionary. get methods for each of the data members (get_name and get_catalog). a method named add_movie that takes a Movie…arrow_forwardDirections: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Notes: • Assume that the classes listed in the Java Quick Reference have been imported where appropriate. • Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. • In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit. Consider a guessing game in which a player tries to guess a hidden word. The hidden word contains only capital letters and has a length known to the player. A guess contains only capital letters and has the same length as the hidden word. After a guess is made, the player is given a hint that is based on a comparison between the hidden word and the guess. Each position in the…arrow_forward
- !! E! 4 2 You are in process of writing a class definition for the class Book. It has three data attributes: book title, book author, and book publisher. The data attributes should be private. In Python, write an initializer method that will be part of your class definition. The attributes will be initialized with parameters that are passed to the method from the main program. Note: You do not need to write the entire class definition, only the initializer method lili lilıarrow_forwardWhich of the following statements is false? a. A class can contain only one constructor. b. An example of a behavior is the SetTime method in a Time class. c. An object created from a class is referred to as an instance of the class. d. An instance of a class is considered an object.arrow_forwardUsing import sys : Create a python program called classname.py. The program should define a classcalled person that has one method called hello, and one attribute called name,which represents the name of the person.arrow_forward
- Which one of the following statements is FALSE? File Transfer Protocol (FTP) is a TCP service that operates on ports 20 and 21. Telnet is a TCP service that operates on port 23. Simple Network Management Protocol (SNMP) is a TCP service that operates on port 25. Dynamic Host Configuration Protocol (DHCP) is a TCP service that operates on port 80.arrow_forwardplease do both parts 1)Create two Java classes, Desktop and Laptop that both are subclasses of Computer.a) A Desktop has additional instance variables: width and height (data encapsulation isexpected)b) A Laptop has an additional instance variable, weight (data encapsulation is expected).c) Write constructors for both classes that require input for all their instance variables(including Manufacturing Date, Disk size, Number of cores and Color) and no-argsconstructors.d) Create getters and setters for all instance variables for both Child classes.e) Create toString() methods in Desktop and Laptop. 2) Test Two Child ClassesTest your newly created subclasses inside the same TestComputer program you previouslycreated: create two new Laptops and two new Desktops with the data of your choice. UsetoString() method to show all data fields (including the data fields in the super class and sub class).arrow_forward1. Consider the following Python code and answer the following questions. Identify the parent and child classes here? What is the output of the code? (Try figuring it out first without running the program) What do we need to do so that self.data for class Hospital is initialized to an integer taken from the user? Update the code that needs to be added or changed. 2. class PatientCare(object): def __init__(self): print('I am the patientcare, parent class') print(self.data = 12) class Emergency(PatientCare): def __init__(self): print('I am the Emergency') PatientCare.__init__(self) print(self.data = 10) class Clinic(PatientCare): def __init__(self): print('I am the clinic') PatientCare.__init__(self) print(self.data = 8) class Hospital (Emergency, Clinic): def __init__(self): print('I am the hospital') Clinic. _init__(self) Emergency._init__(self) print(self.data = 6) NMC_hospital Hospital() Draw a UML class diagram representing the hierarchy created by the following header declarations.…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