Share
Explore BrainMass

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.

Solution Preview

---------------- Service.java -----------------

import java.util.*;
public class Service implements Comparable< Service> {

private String serv;
private double price;
private int time;
public Service(String s,double p,int t)
{
serv = s;
price = p;
time = t;
}
public String get_serv_name()
{
return serv;
}

public double get_serv_price()
{
return price;
}

public int get_serv_time()
{
return time;
}

public int compareTo(Service new_ob) {

//int n_time = new_ob.get_serv_time();

//ascending order
return this.time - new_ob.get_serv_time();

//descending order
//return compareQuantity - ...

Solution Summary

Solution contains full Java program and follows the naming convention to make it easier for the reader to understand code.

$2.19