1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vivado [14]
2 years ago
15

Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int

for the minutes, and an int for the seconds. The class should include a threeargument constructor and get and set methods for each instance variable. Override the method toString which should return the Clock information in the same format as the input file (See below). Read the information about a Clock from a file that will be given to you on Blackboard, parse out the three pieces of information for the Clock using a StringTokenizer, instantiate the Clock and store the Clock object in two different arrays (one of these arrays will be sorted in a later step). Once the file has been read and the arrays have been filled, sort one of the arrays by hours using Selection Sort. Display the contents of the arrays in a GUI that has a GridLayout with one row and two columns. The left column should display the Clocks in the order read from the file, and the right column should display the Clocks in sorted order.
Computers and Technology
1 answer:
Anvisha [2.4K]2 years ago
3 0

Answer:

public class Clock

{

private int hr; //store hours

private int min;  //store minutes

private int sec; //store seconds

public Clock ()

{

 setTime (0, 0, 0);

}

public Clock (int hours, int minutes, int seconds)

{

 setTime (hours, minutes, seconds);

}

public void setTime (int hours, int minutes, int seconds)

{

 if (0 <= hours && hours < 24)

      hr = hours;

 else

      hr = 0;

 

 if (0 <= minutes && minutes < 60)

      min = minutes;

 else

      min = 0;

 

 if (0 <= seconds && seconds < 60)

      sec = seconds;

 else

      sec = 0;

}

 

 //Method to return the hours

public int getHours ( )

{

 return hr;

}

 //Method to return the minutes

public int getMinutes ( )

{

 return min;

}

 //Method to return the seconds

public int getSeconds ( )

{

 return sec;

}

public void printTime ( )

{

 if (hr < 10)

      System.out.print ("0");

 System.out.print (hr + ":");

 if (min < 10)

      System.out.print ("0");

 System.out.print (min + ":");

 if (sec < 10)

      System.out.print ("0");

 System.out.print (sec);

}

 

 //The time is incremented by one second

 //If the before-increment time is 23:59:59, the time

 //is reset to 00:00:00

public void incrementSeconds ( )

{

 sec++;

 

 if (sec > 59)

 {

  sec = 0;

  incrementMinutes ( );  //increment minutes

 }

}

 ///The time is incremented by one minute

 //If the before-increment time is 23:59:53, the time

 //is reset to 00:00:53

public void incrementMinutes ( )

{

 min++;

 

if (min > 59)

 {

  min = 0;

  incrementHours ( );  //increment hours

 }

}

public void incrementHours ( )

{

 hr++;

 

 if (hr > 23)

     hr = 0;

}

public boolean equals (Clock otherClock)

{

 return (hr == otherClock.hr

  && min == otherClock.min

   && sec == otherClock.sec);

}

}

You might be interested in
.true or false? one disadvantage of cloudware is that it is never free<br> A. true<br> B. false
ser-zykov [4K]

Answer:

true

Explanation:

cloudware is used for many reasons and It is sometimes too much of an expense to the company

7 0
2 years ago
The Zoom slider will allow users to _____.
NeX [460]
The Zoom slider will allow users to change the way the document appears on the screen
3 0
3 years ago
Read 2 more answers
What's exactly the difference between "Library" and "Framework" ? ​
Mariana [72]
Answer:

The key difference between a library and a framework is “Inversion of Control”. When you call a method from a library, you are in control. But with a framework, the control is inverted:the framework calls you

Explanation:

A library performs specific, well-defined operations.

A framework is a skeleton where the application defines the "meat" of the operation by filling out the skeleton. The skeleton still has code to link up the parts but the most important work is done by the application.

Examples of libraries: Network protocols, compression, image manipulation, string utilities, regular expression evaluation, math. Operations are self-contained.

Examples of frameworks: Web application system, Plug-in manager, GUI system. The framework defines the concept but the application defines the fundamental functionality that end-users care about.
8 0
2 years ago
Please help This is a homework in ICT class
Pavlova-9 [17]

Answer:

ejwksjnsskawii28393939393030jedjdjjccjncncnccnnccn

Explanation:

jsskaaaahujpjbhdueiwiwopwpwpwwieuehbfcnnccjxkxooss8ahwhwwnekdodod8djhdmslwoaishwhwkqoq18829293i4644673819191jednsmzljesksowlwlwpwpwnwkpwwwww waaaaayushsjsnmssoss ss sosijw

8 0
2 years ago
Aaron bought a photo-editing software package for personal use. He makes two copies of the software, in case the original softwa
Korvikt [17]

Aaron's action is considered legal, as you are allowed to make a backup copy of a legal copy of a software, but it can only be used in case the original software is destroyed or unusable.

5 0
3 years ago
Other questions:
  • If a database named Contacts has a table named tblEmployees and another database named Orders links to that tblEmployees table,
    8·1 answer
  • How can i learn about networks
    15·1 answer
  • According to the author, there are five hedging strategies organizations can pursue. One of them is: Select one: a. commit with
    5·1 answer
  • Express 0.0005 x 10-4 farads as picofarads
    5·2 answers
  • In which of the following scenarios would you choose to embed versus import data?
    8·1 answer
  • List any two programs that are required to play multimedia products
    8·1 answer
  • Halp me vanajsudhrbfhjrjfjfjf ​
    9·1 answer
  • If anyone gotta ps4, i'm a 15 yr old female n if u wanna b frens, hmu :))
    8·2 answers
  • How do we prevent electrical problems as prescribe by the course?​
    11·1 answer
  • 1. Give one reason why data is represented in binary in a computer [1]
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!