Java Application Help - Inner Class?
-
My program this week is to create an application that will calculate services (oil change, car wash, or both) provided to customers. The services should be totaled and a message box should display the services rendered and the total sales amount for the purchase. Also, the client should be able to clear the application for a new user. For whatever reason, this inner class is confusing me, and I'm not sure that I'm even on the right track. Any help would be greatly appreciated.
import javax.swing.JFrame;
public class CarCareTest {
public static void main(String\[\] args) { CarCare myCarCare = new CarCare(); myCarCare.setSize(500, 500); myCarCare.setVisible(true); myCarCare.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE); }
}
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;public class CarCare extends JFrame {
//Declare Class Variables private JMenuItem bronzeOil, silverOil, goldOil; private JMenuItem basicWash, betterWash, bestWash; private JMenuItem total, clear, exit; private int priceOilChange, priceCarWash; //Create Constructor public CarCare(){ super("Quick Fast Car Care"); //Instantiate Top Level Menu Items JMenu oilchangeMenu = new JMenu ("Oil Change"); JMenu carwashMenu = new JMenu ("Car Wash"); JMenu totalclearexitMenu = new JMenu ("Total/Clear/Exit"); //Instantiate Sub Menu Items bronzeOil = new JMenuItem("Bronze"); silverOil = new JMenuItem("Silver"); goldOil = new JMenuItem("Gold"); basicWash = new JMenuItem("Basic"); betterWash = new JMenuItem("Better"); bestWash = new JMenuItem("Best"); total = new JMenuItem("Total"); clear = new JMenuItem("Clear"); exit = new JMenuItem("Exit"); //Set Layout Manager setLayout(new FlowLayout()); //Add Sub Menu Items To Top Level Menu oilchangeMenu.add(bronzeOil); oilchangeMenu.add(silverOil); oilchangeMenu.add(goldOil); carwashMenu.add(basicWash); carwashMenu.add(betterWash); carwashMenu.add(bestWash); totalclearexitMenu.add(total); totalclearexitMenu.add(clear); totalclearexitMenu.add(exit); //Create Menu Bar JMenuBar bar = new JMenuBar(); //Add Top Level(s) To Menu Bar bar
-
My program this week is to create an application that will calculate services (oil change, car wash, or both) provided to customers. The services should be totaled and a message box should display the services rendered and the total sales amount for the purchase. Also, the client should be able to clear the application for a new user. For whatever reason, this inner class is confusing me, and I'm not sure that I'm even on the right track. Any help would be greatly appreciated.
import javax.swing.JFrame;
public class CarCareTest {
public static void main(String\[\] args) { CarCare myCarCare = new CarCare(); myCarCare.setSize(500, 500); myCarCare.setVisible(true); myCarCare.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE); }
}
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;public class CarCare extends JFrame {
//Declare Class Variables private JMenuItem bronzeOil, silverOil, goldOil; private JMenuItem basicWash, betterWash, bestWash; private JMenuItem total, clear, exit; private int priceOilChange, priceCarWash; //Create Constructor public CarCare(){ super("Quick Fast Car Care"); //Instantiate Top Level Menu Items JMenu oilchangeMenu = new JMenu ("Oil Change"); JMenu carwashMenu = new JMenu ("Car Wash"); JMenu totalclearexitMenu = new JMenu ("Total/Clear/Exit"); //Instantiate Sub Menu Items bronzeOil = new JMenuItem("Bronze"); silverOil = new JMenuItem("Silver"); goldOil = new JMenuItem("Gold"); basicWash = new JMenuItem("Basic"); betterWash = new JMenuItem("Better"); bestWash = new JMenuItem("Best"); total = new JMenuItem("Total"); clear = new JMenuItem("Clear"); exit = new JMenuItem("Exit"); //Set Layout Manager setLayout(new FlowLayout()); //Add Sub Menu Items To Top Level Menu oilchangeMenu.add(bronzeOil); oilchangeMenu.add(silverOil); oilchangeMenu.add(goldOil); carwashMenu.add(basicWash); carwashMenu.add(betterWash); carwashMenu.add(bestWash); totalclearexitMenu.add(total); totalclearexitMenu.add(clear); totalclearexitMenu.add(exit); //Create Menu Bar JMenuBar bar = new JMenuBar(); //Add Top Level(s) To Menu Bar bar
And what is your question? It is pretty much unclear as to how to help you out in this context. Adding an inner class is fair and legal in Java. But, what is the question here? It is the logic that you want to be added or what?
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~