• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Reading Objects and Formatting Ouput

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there! I was hoping I could get a few pointers on the code below!! Ok, here is the background for what I am doing.

1) The program will read the original sales data from SalesData.txt, that will create salesmen and then that information will be entered into the array list Salesman. The file looks like this (just so ya know):

Jones&2&5&3&0&8&SENIOR
Smith&6&0&2&0&5&JUNIOR
Douglas&1&0&7&5&3&ENTRY
Hollins&9&6&3&7&15&ENTRY
Smythe&0&0&0&0&0&SENIOR
Billings&0&7&12&15&2&JUNIOR
Kozak&3&5&8&22&0&ENTRY

2) Each salesman has a level type of ENTRY, JUNIOR, or SENIOR. There will be an enumerated class for the sales type. There is a variable, bonus, associated with each type. The bonus for SENIOR is 15%. The bonus for JUNIOR is 10%, and the bonus for ENTRY is 5%.
3) The user will be able to enter additional data on the GUI, either a new salesman and his product sales or the user can update an existing salesman.
4) Then once all of the data is entered the data will be written to the Salesman.data as objects.
5) Then also added to the GUI will be an additional button that when it is clicked the user will actually read the Salesman.data file, put the information in a vector, sort it, and last prints the information to the output area on the GUI in alphabetical order.
6) I need to create a NoSalesException. This exception will be thrown from calculateSales and handled from the calling method. To handle this exception, I will print a warning message dialog box that states the name of the salesman and that he has no sales.

I have worked on everything with the exception of the NoSalesException.

So, the program compiles fine, but then I believe the reason why it doesn't work properly after entering in all of the additional salesman information is in the readObjectData method. I was wondering if anyone has any tips or ideas for me in that regard, please just let me know if so. I will take any hlep I can get to finish this one up. Also, I am sorry if this is too detailed, I just thought I would give a good description of what I am doing to begin with that way you had a good understanding of what I am trying to do. Again, if anyone has any tips, ideas or help...please please let me know! Much appreciated!!

Sales:


Salesman:


Classification:


Thanks again!!!
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Holly Leery: So, the program compiles fine, but then I believe the reason why it doesn't work properly after entering in all of the additional salesman information is in the readObjectData method.

What exactly is it doing after the readObjectData() method call.

Holly Leery: Again, if anyone has any tips, ideas or help...please please let me know!

A couple of things I see that probably have no relation to the problems you're experiencing. In this section of code:


You never call b.getBonus();. Therefore the Salesman never recieves his proper bonus . Also the calls to close() the streams should be wrapped in a 'finally' block so that the occur even if an IOException occurs.
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh my goodness you are right I didn't do anything with the bonus...obviously I need to go back in a fix that so that that runs properly. Thank you for pointing that out to me! After the program compiles I can enter in any amount of salesman, the amount of a product sold, that prodct and the salesman level, I then click "All Data Entry Done" which writes the data as objects to Salesman.data and then when I click "Grand Total" to read the data back in and post it in the textarea I get the following error:

 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of serializing each Salesman individually, you could just serialize the entire Salesman list:

And then deserailize like this:

[ March 22, 2006: Message edited by: Garrett Rowe ]
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, that makes sense, thank you. Is there a way to format the data to look a certain way and set it in the textarea? What I am doing does not seem to be working properly.
 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I have two parts printing to the output textarea, the TOTAL SALES line and the actual Total line. The individual sales are not being sent though. Could this have to do with the vector? Unfortunetly I am supposed to be using a vector and I think that is part of my problem.

 
Holly Leery
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there! I was hoping someone could help me out! I would really appreacaite it! I am almost completely done with the program, I am just having two small problems. 1) I cannot figure out how to handle the enum class. I have to use bonus in the readFileData() method, but I am not sure how I am supposed to declare it. I keep getting errors no matter what I try. I know it is probably something extreamly simple, but I am just not seeing it. 2) In addSalesman() I am using an ArithmeticException that is originally thrown from CalcSales() where I created an Exception "NoSalesException". Well it is telling me I cannot have this in the JOptionPane...why is this and what can I do to fix it? Also can I put the salesman name in there?


Sales:


Classification:


NoSalesException:


[ March 23, 2006: Message edited by: Holly Leery ]
[ March 23, 2006: Message edited by: Holly Leery ]
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic