Can someone please help me with the main code? The code for the business class is down below. Part I - Design a class named Business that contains: A String attribute named name for the Business name A String attribute named symbol for the Business’s stock symbol A double attribute named lastPrice that stores the stock price one month ago A double attribute named currentPrice that stores the stock price for the current time A default constructor An overloaded constructor that creates a Business with a specified Business stock symbol and name An overloaded constructor with all attributes Accessors and mutators for each attribute A copy Constructor    An Equals Method    A toString() method to display current state of the object, formatted! Part 2- Create a BusinessDriver application. You will have at least 4 methods in this application main() – setBusinessData() - this reads the data from the file (call the file businessData.txt) displayBusinessData() - this displays the data to the screen, calling the toString() method of all objects sortData() - This will sort the data by choice either name of stock or current price. Pick one. Create an arraylist of the 10 Business objects Create a menu: Options 1 = List the objects in the arraylist 2 = List just the Business names of the array list 3 = List just the Business Name and current stock price 4  = Sort by name or by price Your choice 5 = Exit Read the data for the array from a file (see below) Call each method as described above then list the menu and loop until the user exits.   BusinessData.txt (the data is set up like this: Business symbol, Business name, lastprice, current price - copy and paste this into a .txt file) GPRO   GoPro, Inc. 10.71 13.69 SBUX Starbucks 59.53 58.46 JCP JC Penney 7.73 10.78 AMZN Amazon 531.07 576.32 AE Adams Resources and Energy 34.96 33.77 KO Coca-Cola 42.72 43.60 MCD McDonald's 121.47 115.99 TSLA Tesla Motors 173.48 187.90 AAPL Apple Inc 96.35 100.67 FB Facebook 112.69 108.93 ------------------------------------CLASS CODE------------------------- public class Business { private String businessSymbol; private String businessName; private double lastPrice; private double currentPrice; public Business() { businessSymbol = " "; businessName = " "; lastPrice = 0; currentPrice = 0; } public Business(String businessName, String businessSymbol) { this.businessSymbol = businessSymbol; this.businessName = businessName; } public Business(String businessName, String businessSymbol, double lastPrice, double currentPrice) { this.businessSymbol = businessSymbol; this.businessName = businessName; this.lastPrice = lastPrice; this.currentPrice = currentPrice; } // The copy constructor public Business(Business business) { this.businessSymbol = business.businessSymbol; this.businessName = business.businessName; this.lastPrice = business.lastPrice; this.currentPrice = business.currentPrice; }   public void setBussinessName(String businessName) { this.businessName = businessName; } public String getBussinessName() { return businessName; } public void setLastPrice(double lastPrice) { this.lastPrice = lastPrice; } public double getLastPrice() { return lastPrice; } public void setCurrentPrice(double currentPrice) { this.currentPrice = currentPrice; } public double getCurrentPrice() { return currentPrice; } public boolean equals(Business someBusiness) { boolean same = false; if(businessSymbol.equalsIgnoreCase(someBusiness.businessSymbol) && businessName.equalsIgnoreCase(someBusiness.businessName) && lastPrice == (someBusiness.lastPrice) && currentPrice ==(someBusiness.currentPrice)) same = true; return same; } public String toString() { String str = " "; return "\nBusiness symbol: " + businessSymbol + "\nBusiness name: " + businessName + "\nLast price: " + lastPrice + "\nCurrent price: " + currentPrice; }   }//end class

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 5RQ
icon
Related questions
Question
100%

Can someone please help me with the main code? The code for the business class is down below.

Part I - Design a class named Business that contains:

  • A String attribute named name for the Business name
  • A String attribute named symbol for the Business’s stock symbol
  • A double attribute named lastPrice that stores the stock price one month ago
  • A double attribute named currentPrice that stores the stock price for the current time
  • A default constructor
  • An overloaded constructor that creates a Business with a specified Business stock symbol and name
  • An overloaded constructor with all attributes
  • Accessors and mutators for each attribute
  • A copy Constructor   
  • An Equals Method   
  • A toString() method to display current state of the object, formatted!

Part 2- Create a BusinessDriver application.

  • You will have at least 4 methods in this application
    • main() –
    • setBusinessData() - this reads the data from the file (call the file businessData.txt)
    • displayBusinessData() - this displays the data to the screen, calling the toString() method of all objects
    • sortData() - This will sort the data by choice either name of stock or current price. Pick one.
  • Create an arraylist of the 10 Business objects
  • Create a menu:
  • Options
  • 1 = List the objects in the arraylist
  • 2 = List just the Business names of the array list
  • 3 = List just the Business Name and current stock price
  • 4  = Sort by name or by price Your choice
  • 5 = Exit
  • Read the data for the array from a file (see below)
  • Call each method as described above then list the menu and loop until the user exits.

 

BusinessData.txt (the data is set up like this: Business symbol, Business name, lastprice, current price - copy and paste this into a .txt file)

GPRO  
GoPro, Inc.
10.71
13.69
SBUX
Starbucks
59.53
58.46
JCP
JC Penney
7.73
10.78
AMZN
Amazon
531.07
576.32
AE
Adams Resources and Energy
34.96
33.77
KO
Coca-Cola
42.72
43.60
MCD
McDonald's
121.47
115.99
TSLA
Tesla Motors
173.48
187.90
AAPL
Apple Inc
96.35
100.67
FB
Facebook
112.69
108.93

------------------------------------CLASS CODE-------------------------

public class Business
{

private String businessSymbol;

private String businessName;


private double lastPrice;


private double currentPrice;


public Business()
{
businessSymbol = " ";

businessName = " ";

lastPrice = 0;

currentPrice = 0;
}


public Business(String businessName, String businessSymbol)
{
this.businessSymbol = businessSymbol;

this.businessName = businessName;

}



public Business(String businessName, String businessSymbol, double lastPrice, double currentPrice)
{
this.businessSymbol = businessSymbol;

this.businessName = businessName;

this.lastPrice = lastPrice;

this.currentPrice = currentPrice;
}

// The copy constructor

public Business(Business business)
{
this.businessSymbol = business.businessSymbol;

this.businessName = business.businessName;

this.lastPrice = business.lastPrice;

this.currentPrice = business.currentPrice;
}

 

public void setBussinessName(String businessName)
{

this.businessName = businessName;
}

public String getBussinessName()
{
return businessName;
}


public void setLastPrice(double lastPrice)
{
this.lastPrice = lastPrice;
}


public double getLastPrice()
{
return lastPrice;
}


public void setCurrentPrice(double currentPrice)
{
this.currentPrice = currentPrice;


}


public double getCurrentPrice()
{
return currentPrice;
}


public boolean equals(Business someBusiness)
{
boolean same = false;

if(businessSymbol.equalsIgnoreCase(someBusiness.businessSymbol) &&
businessName.equalsIgnoreCase(someBusiness.businessName) &&
lastPrice == (someBusiness.lastPrice) &&
currentPrice ==(someBusiness.currentPrice))

same = true;

return same;
}


public String toString()
{
String str = " ";
return "\nBusiness symbol: " + businessSymbol + "\nBusiness name: " + businessName + "\nLast price: " + lastPrice + "\nCurrent price: " + currentPrice;

}

 

}//end class

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage