Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Java Application Help - Inner Class?

Java Application Help - Inner Class?

Scheduled Pinned Locked Moved Java
javasaleshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 10694570
    wrote on last edited by
    #1

    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
    
    A 1 Reply Last reply
    0
    • U User 10694570

      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
      
      A Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #2

      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 !~

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups