Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Violacion al principio OCP #6

Open
GiancarloAyrton opened this issue Nov 12, 2021 · 0 comments
Open

Violacion al principio OCP #6

GiancarloAyrton opened this issue Nov 12, 2021 · 0 comments

Comments

@GiancarloAyrton
Copy link

public interface Resource{
int findFree();
void markBusy(int resourceId);
void markFree(int resourceId);
}
public class SpaceResource implements Resource{
@OverRide
public int findFree(){
return 0;
}
@OverRide
public void markBusy(int resourceId){

}
@Override
public void markFree(int resourceId){
}

}
public class TimeResource implements Resource{
@OverRide
public int findFree(){
return 0;
}
@OverRide
public void markBusy(int resourceId){
}
@OverRide
public void markFree(int resourceId){
}
}
public class ResourceAllocator{
public int allocate(Resource resource)
{
int resourceId = resource.findFree();
resource.markBusy(resourceId);
return resourceId;
}

public void free(Resource resource, int resourceId)
{
    resource.markFree(resourceId);
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant