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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:45:16+00:00 2026-05-30T22:45:16+00:00

I am having a bit of trouble with the design aspect of my JAVA

  • 0

I am having a bit of trouble with the design aspect of my JAVA program, there a couple of ways in which I have thought of doing, but I dont know which way is best, or if there is a better way to do it?. Below is an example of one way

                         << ABSTRACT >>
                           Rooms class

      extends                extends         extends
   Room TYPE U            Connector X      Connector U


             AGGREGATE walls - into each room type

The reason why I am getting a bit confused is that the 3 different types of rooms that I am using only differ in there property values(height,width etc..), but all have the same properties. Does this warrant creating a new class for EACH room type?.

Or should I do it the other way which is having the one rooms class and instantiating it three times for each room type and just changing its properties via setters and getters?.

because I would have to set each rooms properties and its aggregated wall properties which could get quite long!.

Any help is greatly 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-05-30T22:45:17+00:00Added an answer on May 30, 2026 at 10:45 pm

    If the rooms only differ by their property values, consider using a factory-style pattern. Here’s a simple example:

    class Room {
    
         // room properties
         int x, y, z;
    
         // constructor taking properties
         public Room (int x, int y, int z) {
             this.x = x;
             this.y = y;
             this.z = z;
         }
    
         // factory methods
         public static Room createRoomType1() {
             return new Room(100, 200, 300);
         }
    
         public static Room createRoomType2() {
             return new Room(400, 500, 600);
         }
    
    }
    

    The factory methods are like “preset” constructors for different types of rooms. This strikes a balance between repetition/property setting, and having too many classes.

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

Sidebar

Related Questions

I'm having a bit of a trouble understanding how to fit a particular design
Having a bit of trouble using the List.Find with a custom predicate i have
Having a bit of trouble getting this right... The main objective is to have
I am having a bit of trouble understanding how I will design a class.
I am having a bit of trouble figuring this one out, basically I have
I'm having a bit trouble with a query in Linq to Entities which I
having a bit of trouble adding some data to a database. I have the
This question is a bit of a structural/design question as I'm having trouble working
I have having a little trouble wrapping my head around the design pattern for
Im having a bit of trouble with this regex. I have a line that

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.