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 8959153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:22:49+00:00 2026-06-15T15:22:49+00:00

I am having trouble with my explore method() I have to create a picture

  • 0

I am having trouble with my explore method()
I have to create a picture whose height is the max of the heights, and width is the
sum of the widths of the stored pictures.The pictures in the Album should be copied so far are copied into a new picture and that picture is displayed by calling the explore() method on it.
This is what I have:

public boolean addPicture( Picture thePicture, int where )
{
int index = nPictsInAlbum;
pictArray[index] = pictArray[index-1];

while( index > where )
{
pictArray[where] = thePicture;
nPictsInAlbum ++;
}
return true;
}

public void explore()
{    
int maxHeight = 0;  //max height for the picture
int value = 0;
int biggest = 0;

for(int i = 0; i < pictArray.length; i++)
{
nPictsInAlbum = pictArray[i];
if(value > maxHeight)
{
biggest = value;
maxHeight = i;
}
}
  • 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-15T15:22:50+00:00Added an answer on June 15, 2026 at 3:22 pm

    I’m assuming that the variable biggest is the variable that is holding the total width.

    You are doing a few things wrong with your code, and you’ll have to fix these first

    1. You are reusing the nPictsInAlbum multiple times for different types of variables. You shouldn’t do that. I’m not a java programmer but it is at least a bad practice in other languages because it causes confusion. You use that variable in the addPicture method to track the latest index. But in the explore method, you use it to temporarily store an individual picture that you’re accessing.

    2. In the explore method, you are not accessing the properties\fields of the picture object. Without knowing what properties\fields a picture object has, we cannot correct your code entirely.

    If you fix those two problems, then the logic errors you have in the explore method are

    1. (assuming that the variable biggest is the total width, if so you should rename it to be more descriptive) You are only setting the total width when you have figured out that the height of the current picture you have is bigger in height than a previously stored picture. You need to always set total width when you loop each picture regardless.

    2. When you set the total width of the picture, you are replacing the total, not adding it. in your example biggest = value would not add it. You would want biggest = biggest + value to do that


    You want to make sure to take your time when you make the methods. Tactfully think about what is it going to do, what variables will you need, what other variables will you access, and what will you do with them. For example, if the point of explore is to determine the max height and total width you would think like this:

    1. I need a reusable piece of code that will determine the maximum height out of all pictures. It will also get a total width of all pictures.
    2. Therefore I will need two variables: maxHeight and totalWidth.
    3. From this code I need iterate over an array of pictures.
    4. In that loop, I need to check to see if the picture’s height is greater then maxHeight. If so, I need to set maxHeight to the picture’s height
    5. To access the picture’s height, I would need to use the (I don’t know what the picture’s object structure is so I’m guessing) picture.height property.
    6. Regardless of the height of the picture, I need to add the width of the picture to a running total. So I would use totalWidth = totalWidth + picture.width

    Hope this helps you to get your code cleaned up and working better.

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

Sidebar

Related Questions

Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
I'm using jQuery 1.3.2. I'm having trouble getting a correct height in Internet Explorer
I have php two servers with different versions of php, and am having trouble
I have the jsf code and css code below. I'm having trouble getting the
In TFS2010 I am having trouble creating Build Definitions . I have created a
Having trouble with each function... Will try to explain by example... In my code,
Having trouble with an .htaccess file on WAMP. Works on the live server, but
Having trouble accessing javascript code in a mixed html/js ajax response. jQuery ajax doc
Having trouble understanding how to filter an images table by tag information in a
Having trouble understanding. With the following css : .bloc .field:nth-last-child(2){ ...some values... } and

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.