Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9268081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:43:03+00:00 2026-06-18T14:43:03+00:00

(I’m using Java therefore added the ‘Java’ tag incase it influences any answers, however

  • 0

(I’m using Java therefore added the ‘Java’ tag incase it influences any answers, however some may argue that the tag is unecessary.)

Consider the following:

I have a veranda/balcony to plan graphically. As part of the final plan I am required to list any materials required to construct the veranda. To simplify the calculating process I’ve split the veranda into different Sections:

Above Deck – which involves the plastic fencing components and fixings (i.e Screws, bolts)
Below Deck – which involves timber subframes and more fixings.

…Plus others which I won’t go in depth.

For arguments sake: There are 100 different stock items available due to the different fencing designs we offer. Each item has its own class including information such as dimensions, colour, quantity and its ID reference.

What I would like to do is create a list of fixings required for each section and add them all up into one final list without any duplications.
The final idea is to display the item name and a quantity next to the processed plan.

So for example:

Section 1 requires:
– 25 x Screw A

– 15 x Screw B
– 5 x Screw C

Section 2 requires:
– 25 x Screw A

– 15 x Screw B
– 5 x Screw F

Section 3 requires:
– 45 x Screw B

– 50 x Screw C
– 24 x Screw G

Total List
Section 1 + Section 2 + Section 3 = {Complete list of materials}


What I’ve tried/considered:

All the screws I’ve mentioned above have their own class and extend the super class “Fasteners”. Each Section mentioned above has a variable:

ArrayList<Fasteners>

So as I’m calculating I can add the screws to this variable. Once each section has calculated how many Fasteners it requires I then add them altogether.

I’ve considered making a “add(Fixings)” method in the “Fasteners” super class which adds any duplicate items together. But because there are 100 items I would of thought the coding wouldn’t be very efficient and suspect there is a better way of making use of the polymorphism I’ve set up here. Any online references or hints would be helpful and very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:43:04+00:00Added an answer on June 18, 2026 at 2:43 pm

    Here’s a suggestion:

    Make an enum called FastenerType, then use an EnumMap<FastenerType, AtomicInteger> to hold your fasteners. Let’s call it the bag.

    Then do something like

    public class FastenerBag {
    
      private Map<FastenerType, AtomicInteger> fasteners = new EnumMap<FastenerType, AtomicInteger>(FastenerType.map);
    
      FastenerBag(){
        // init your ints to zero
      }
    
      public void addFastenersFor(VerandaPart part){
        for (FastenerType type : FastenerType.values()){
          fasteners.get(type).addAndGet(part.getRequiredFasteners().get(type));
        }
      }
    
    }
    

    Don’t worry too much about performance. First get it working. Then get it readable (refactor), then optimize.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have thousands of HTML files to process using Groovy/Java and I need to
I'm using an ASP request returning a XML file containing some latin characters. By
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.