Part 1 Create a UML class diagram for the Time class as described below: The class will have two integer instance variables representing hours and minutes. These will be stored in standard 24-hour time. The class must have the following methods: a default constructor that sets the time to midnight • a constructor that takes two integer variables representing the hours in 24- hour time (0-23) and the minutes in the range 0-59. This constructor will validate the constructor inputs and will set the time to midnight if either value is outside of the needed range. • a constructor that takes two integers and a string. The string must be either "AM" or "PM", and the integer will be the hours in the range 1-12 and the minutes in the range 0-60. Again, the constructor will validate the constructor inputs and will set the time to midnight if either value is outside of the needed range or the String is not "AM", "am", "PM", or "pm". • getters and setters for the hours and minutes. The setters must validate the input values and will not change the time unless the value is in valid 24 hour time range. • an equals method .toString-returns a String with the time in the form hh:mm, where hh can range from 00 to 23. • get 12 HourTime - returns a String with the time in the form hh:mm AM or hh:mm PM Create test data for 2 different Time objects (in addition to the samples below) and the results of calling methods with various inputs. Have at least 2 different method calls each for the setters, equals, toString, and get 12HourTime methods, trying to test different situations. You may use the sample objects below in your own tests. Sample test data: Code: Time timel new Time (2,30); Expected result: timel object created with hours: 2 and minutes: 30 Code: Time time2= new Time (2,45, "PM"); Expected result: timel object created with hours: 14 and minutes: 45 Code: Time time3= new Time (14,45); Expected result: timel object created with hours: 14 and minutes: 45 Code: Time time4 = new Time (25,50); 1 Espected result: time4 object created with hours: 0 and minutes: 0 (midnight - because of invalid. input) Code: time3.setMinutes (68); Expected result: time3 object not changed because of invalid input. Code: System.out.println(time3.equals(time2)); Expected result: true printed to console Code: System.out.println(time3); // calls time3.toString() automatically Expected result: 14:45 printed to console Code: Expected result: 2:45 PM printed to console 2 System.out.println(time3.get12Hour Time());
Part 1 Create a UML class diagram for the Time class as described below: The class will have two integer instance variables representing hours and minutes. These will be stored in standard 24-hour time. The class must have the following methods: a default constructor that sets the time to midnight • a constructor that takes two integer variables representing the hours in 24- hour time (0-23) and the minutes in the range 0-59. This constructor will validate the constructor inputs and will set the time to midnight if either value is outside of the needed range. • a constructor that takes two integers and a string. The string must be either "AM" or "PM", and the integer will be the hours in the range 1-12 and the minutes in the range 0-60. Again, the constructor will validate the constructor inputs and will set the time to midnight if either value is outside of the needed range or the String is not "AM", "am", "PM", or "pm". • getters and setters for the hours and minutes. The setters must validate the input values and will not change the time unless the value is in valid 24 hour time range. • an equals method .toString-returns a String with the time in the form hh:mm, where hh can range from 00 to 23. • get 12 HourTime - returns a String with the time in the form hh:mm AM or hh:mm PM Create test data for 2 different Time objects (in addition to the samples below) and the results of calling methods with various inputs. Have at least 2 different method calls each for the setters, equals, toString, and get 12HourTime methods, trying to test different situations. You may use the sample objects below in your own tests. Sample test data: Code: Time timel new Time (2,30); Expected result: timel object created with hours: 2 and minutes: 30 Code: Time time2= new Time (2,45, "PM"); Expected result: timel object created with hours: 14 and minutes: 45 Code: Time time3= new Time (14,45); Expected result: timel object created with hours: 14 and minutes: 45 Code: Time time4 = new Time (25,50); 1 Espected result: time4 object created with hours: 0 and minutes: 0 (midnight - because of invalid. input) Code: time3.setMinutes (68); Expected result: time3 object not changed because of invalid input. Code: System.out.println(time3.equals(time2)); Expected result: true printed to console Code: System.out.println(time3); // calls time3.toString() automatically Expected result: 14:45 printed to console Code: Expected result: 2:45 PM printed to console 2 System.out.println(time3.get12Hour Time());
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Concept explainers
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Question
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 now
This is a popular solution!
Step by step
Solved 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.Recommended textbooks for you
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
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