• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Turning an application into an object

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this exercise, you'll create an Invoice class and construct objects from it as you conver the Invoice application to an object-oriented application.

1. Open the InvoiceApp and Validator classes in the directory. This is yet another version of the Invoice application. Then, compile and run the classes to see how this application works.

2.include two private fields for customer type and subtotal entered by user.
Include single constructor that accepts the customer type and subtotal as parameters.
include get method that returns the subtotal as a double value and a get methods that calculate and return double values for the discount percent, discount amount and total.
Include get methods that return formatted string values for the subtotal, discount percent, discount amount and total. These methods should call the other get methods to get the values to be formatted.
Include a get method that returns a string that contains the full name for a customer type.

3. Modify the code in the InvoiceApp classes so it creates an Invoice object and uses its getInvoice method to get the formatted data fro invoice. That should simplify this class considerably. Then compile and test this class to make sure that this application works the way it did in step 1.

I'm pretty sure I got most of this. I can't figure out why my if and else if statements are wrong.

Validator

What I've come up with


Any help would be greatly appreciated as I am totally lost.
Thanks
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your Invoice class won't even compile. I think you may have pasted it incorrectly.

What specific if/else blocks are you having problems with? And could you elaborate on the problems?
 
Tianna Taylor-Albin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's supposed to be an invoice app that asks the customer for customer type and subtotal. A discount is given depending on the customer type. It should calculate the total based on the subtotal and discount amount.The invoice class (the one at the bottom) is where the bad if and if else statements are. I think that is what is keeping it from compiling. I can't figure out why they are wrong. NetBeans says it's an "illegal start of type <identifier> expected illegal start of type" error. I'm not sure what that means because I copied it directly from the Invoice App class.
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tianna Taylor-Albin wrote:I'm not sure what that means because I copied it directly from the Invoice App class.


It appears to be lines 31 - 46 of your Invoice class that you copied from the InvoiceApp class. Notice however that in the InvoiceApp class those lines are inside a method whereas in your Invoice class they are not. You can only have variable declarations outside of a method or constructor and that's why the compiler is complaining about the if statement.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic