Explore BrainMass
Share

A Java Class for Time

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Modify class Time2 of Fig. 8.5 to include a tick method that increments the time stored in a Time2 object by one second. Provide method incrementMinute to increment the minute and method incrementHour to increment the hour. The Time2 object should always remain in a consistent state. Write a program that tests the tick method, the increment-Minute method and the incrementHour method to ensure that they work correctly. Be sure to test the following cases:

© BrainMass Inc. brainmass.com October 24, 2018, 9:50 pm ad1c9bdddf
https://brainmass.com/computer-science/java/a-java-class-for-time-139426

Attachments

Solution Preview

There are two files: Time2.java is the .java class to handle second ticks and the Time2Test.java that tests the The set methods incorporate error handling, therefore simply adding 1 to the previous values of second/minute/hour works. You can add the following four methods. Notice how incrementSecond() ...

Solution Summary

Solution includes two files: Time2.java is the .java class to handle second ticks and the Time2Test.java that tests the The set methods incorporate error handling, therefore simply adding 1 to the previous values of second/minute/hour works. You can add the following four methods. Notice how incrementSecond() triggers incrementMinute() when seconds exceed 59 and incrementMinute() triggers incrementHour when minute exceeds 59.

$2.19
See Also This Related BrainMass Solution

Java Class for services offered by a hair-styling salon.

The Curl Up and Dye Salon offers a variety of salon services for its customers. Jane Fields, the owner, has contracted to have you write a program that allows reports to be output, sorted by each type of service offered. Table below shows the various services, service prices, and service times.

Service Price($) Time(Minutes)

Cut 8.00 15
Shampoo 4.00 10
Manicure 18.00 30
Style 48.00 55
Permanent 18.00 35
Trim 6.00 5

Create a class for services offered by a hair-styling salon. Data fields include a String to hold the service description (for example, "Cut," Shampoo", or "Manicure"), a double to hold the price, and an integer to hold the average number of minutes it takes to perform the service. The class name is Service. Include a constructor that requires arguments for all three data fields and three get methods that return each one of the data field's values.

Write an application named SalonReport that contains an array to hold six Service Objects and fill it with data from the table above. Include methods to sort the array in ascending order by price of service, time it takes to perform the service, and in alphabetical order by service description.

Prompt the user for the preferred sorting method, and offer three choices: sort by description, price or time. Depending on the user's input, display the results.

View Full Posting Details