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

  • Home
  • SEARCH
  • 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 7458461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:27:01+00:00 2026-05-29T13:27:01+00:00

I have similar fun task from my university. For example, there is ClassA. I

  • 0

I have similar fun task from my university. For example, there is ClassA. I need to limit access to object that if today is sunday client can’t make ClassA object or using existing ClassA objects. I think I need to make some wrapper for class because otherwise I need to make checking conditiong of day in each method of ClassA. Is there any desing patters for it? Please, I hope you can help me.

  • 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-29T13:27:02+00:00Added an answer on May 29, 2026 at 1:27 pm

    Factory pattern is what you are looking for. You pass the arguments to a factory class (the “wrapper”) and it takes care of creating the right kind of object. For example:

    class ClassA implements MyInterface { ... }
    class ClassB implements MyInterface { ... }
    
    class MyFactory {
        public MyInterface create(int dayOfTheWeek) {
            if (dayOfTheWeek == 0) {
                return new ClassA();
            } else {
                return new ClassB();
            }
        }
    }
    

    When you need a new object, MyFactory decides the actual class:

    MyFactory factory = new MyFactory();
    MyInterface object = factory.create(dayOfTheWeek);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For testing purposes I need to create sets of text files that have similar
I have a few tables that have similar fields but not exactly the same.
I am maintaining several Perl scripts that all have similar code blocks for different
The following code returns the error from the For Each loop. I have similar
I have a form that has a few similar controls and the parent contains
I have a collection of elements that I need to operate over, calling member
I have similar problem as is described in Spring Framework - New object is
I have similar methods that needs to be implemented for different concepts. But call
I have a text file that looks similar to; section header 1: some words
I've consulted a similar thread to the following code that I have so far.

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.