Thanks for the question. Here is the code for Part B. Also the bonus function has been implemented.
(thanks and please a thumbs up !)
====================================================================================
class Time(): def __init__(self,hour=0,minutes=0,seconds=0): self.__hour=hour self.__mins=minutes self.__secs=seconds def __repr__(self): secs=mins=hour='0' if self.__hour<10: hour+=str(self.__hour) else: hour=str(self.__hour) if self.__mins<10: mins+=str(self.__mins) else: mins=str(self.__mins) if self.__secs<10: secs+=str(self.__secs) else: secs=str(self.__secs) return 'Class Time: {0}:{1}:{2}'.format(hour,mins,secs) def __str__(self): secs=mins=hour='0' if self.__hour<10: hour+=str(self.__hour) else: hour=str(self.__hour) if self.__mins<10: mins+=str(self.__mins) else: mins=str(self.__mins) if self.__secs<10: secs+=str(self.__secs) else: secs=str(self.__secs) return '{0}:{1}:{2}'.format(hour,mins,secs) def from_str(self,time): time=time.split(':') self.__hour=int(time[0]) self.__mins=int(time[1]) self.__secs=int(time[2]) @classmethod def add_times(self,t1,t2): hours=t1.__hour+t2.__hour mins=t1.__mins+t2.__mins secs=t1.__secs+t2.__secs mins+=secs//60 hours+=mins//60 hours=hours%60 mins=mins%60 secs=secs%60 return Time(hours,mins,secs) A=Time(7,12,3) print(A) A.from_str('07:12:03') print(A) B=Time(1,48,57) print(Time.add_times(A,B))
=====================================================================================
Lab Exercise #11 Assignment Overview You will work with a partner on this exercise during your la...
Can someone please help me with the following java assignment. So in this assignment you will begin with the starterProject I provide and then add to it. I am also asking that before you begin you really look at the starterProject because this is the object-oriented basics. The starterProject is the exact same as the ClassClockExample.zip in Module 5. I’ve also done this using a clock because it is something that you already know how it works. Remember that OOD and OOP is...
Exercise 11 - in Java please complete the following: For this exercise, you need to work on your own. In this exercise you will write the implementation of the pre-written implementation of the class CAR. The class CAR has the following data and methods listed below: . Data fields: A String model that stores the car model, and an int year that stores the year the car was built. . Default constructor . Overloaded constructor that passes values for both...
CSCI 161 - Lab 2: "Give Me a Second!" Overview This lab will have you developing a program that asks the user to input a time period as a number of seconds and in turn calculates the whole number of days, hours and minutes that are contained within the entered time period. Refer to the "Output Format" below for an example of what your program must do. The objectives of this lab are to reinforce and help teach: proper Java...
This assignment uses functions, files, and strings. Enough flexibility is provided for you to apply your knowledge of basic C++ programing to develop your solution. Develop a functional flowchart and then write a C++ program to solve the following problem. 1. Create a text file named file1.txt and write your brand of car (like Honda, Toyota, etc) in the file. You will be reading the name of the file from the keyboard as a string, using the string class. Your...
IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....
Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...
please do a and b Lab Exercise 9 Assignment Overview This lab exercise provides practice with dictionaries of lists and sets in Python. A. Write a program using Dictionaries of lists Consider the file named "lab9a.ру" Given two files named exactly continents. txt and cities.txt (no error checking of the file name is needed) of continents, countries and cities. Write a program to read continents, countries and their cities, put them in a nested dictionary and print them (no duplicates...
3. write a c++ program: Design and implement a class called Clock that describes the time of a clock: a) Include in the class 3 constructors with one, two, and three parameters to set the hours, the minutes, and the seconds, respectively. b) Include also a default constructor that sets the member variables of the class to 00:00:00. c) Write a member function to increment the time by a given amount, and second member function to reset the clock. The...
Please use my Lab 3.2 code for this assignment Lab 4.2 instruction Using the code from lab 4.1, add the ability to read from a file. Modify the input function: * Move the input function out of the Cargo class to just below the end of the Cargo class * At the bottom of the input function, declare a Cargo object named temp using the constructor that takes the six parameters. * Use the Cargo output...
// Enter your name as a comment for program identification // Program assignment testEmployeeAB.cpp // Enter your class section, and time /* The program testEmployeeAB.cpp tests the class Employee. The class Date is included so that the Employee class can use the Date data type. */ /* Data is entered to create an employee data file. */ /* A payroll report and equal employment opportunity report showing ethnicity data is displayed. */ //header files /* use the correct preprocessor directives...