Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stuck in my project:Fill the ship with products in java(max efficiency)  RSS feed

 
dylan payne
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I will start my simple project but I still confuse about the main points.

Here basic story of my project: Imagine that one little ship has got one big store place.We also know exactly measurements of the this storage place.
For example:storage place dimensions length=50 meters, height=15meters, width=20meters

Users should add input values(x,y,z) of products in the storage.I will declare some variables like x(length), y(height), z(width) for product sizes.

And I want to fill the storage with maximum efficiency.So how should I start, and which type methods should I use and I need some advice ty guys
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The start point is writing down the algorithm that will calculate this.
And that doesn't involve code.

There must be some for loading cargo.
 
Randall Twede
Ranch Hand
Posts: 4690
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't tell the whole story, so I can't help you.
 
dylan payne
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:

Randall Twede wrote:


Hey guys,

Here my codes, I wrote some points but I couldn't create 3d product objects, just calculatin x,y,z and collecting in same columns.But system has to collect product by product.

Container.java (storage page)




Product.java (Product page)




Main.java (Main Page)

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't help me, because I have no idea what the algorithm for cargo loading is.
All I can ask is "does it work?"
 
dylan payne
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:The code doesn't help me, because I have no idea what the algorithm for cargo loading is.
All I can ask is "does it work?"


When I try to run it. x, y and z dimensions just collecting in same type. For example when we add two products ( first product x:3 y:4 z:5 second product x:6 y:7 z:8 output-->x:9 y:11 z:13) just collection same type columns and its wrong because we have to calculate 3d objects.These codes are not recognise 3d objects just calculating same column values.Sorry my poor english
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to remember...we have NO IDEA what you are trying to do. For example, you state:

when we add two products ( first product x:3 y:4 z:5 second product x:6 y:7 z:8 output-->x:9 y:11 z:13) just collection same type columns and its wrong because we have to calculate 3d objects


WHY is that wrong? What do you expect the correct answer to be? What is your algorithm that defines "adding two products"? You need to tell us in English - not in code - how you expect to add these two things together.

Also, you need to define what "maximum efficiency" is. If i'm not mistaken, the "packing problem" (which is what I believe this question is about) hasn't been solved, so how you expect do do in in your code escapes me.

You should understand that programming is really 80% THINKING, and only 20% TYPING. If you don't have a rock-solid plan on how to pack the boat before you write your first line of code, you are doomed.
 
Liutauras Vilda
Marshal
Posts: 4649
318
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dylan payne wrote:Here my codes, I wrote some points but I couldn't create 3d product objects, just calculatin x,y,z and collecting in same columns.But system has to collect product by product.
I added your problem to our Beginning Java forum too, that fits to there too, I hope you're fine with that.

Anyway, I've revised your 3 classes you wrote. Please stop right there. Did you draw class diagram?
Honestly, you got full bunch of problems there, starting with poorly chosen variable names "iteratorX/Y/Z" and going towards all that code crammed to a main method without given any context to it what is happening there.

I'm afraid you'll have to start over. I'm sorry to say that.

You might have your assignment requirements somewhere written and could post it here?
 
dylan payne
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:


Imagine 3d room defining dimentions with x(length), y(height), z(width).I will declare room sizes and start to throw some products in it.Until completely filled.For example room length 1000, we are used 999 and next product is more than 1 meter so its done system cant throw the next product bec its full filled.User adding products with input method, they will right x,y,z sizes and system will add products in the room.

At the starting point (0,0,0) I want to put the objects one by one in this order but I couldn't create 3d dimension, I just create the dimensions and system still calculating and adding (x,y,z) same values in same columns.How can I make 3d
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!