Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Past Papers/IT2030 - Mock paper.pdf
Binary file not shown.
Binary file added Past Papers/Mock Exam.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Designpattern3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

public interface Action {
public void Do();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

public class Developer {
public static void main(String args[]) {
IDE ide=new IDE();
Receiver intendedreceiver = new Receiver();
System.out.println("Pressed save button!");
SaveAction saveaction = new SaveAction(intendedreceiver);
ide.SetAction(saveaction);
ide.ExecuteAction();

System.out.println("Pressed saveAll button!");
SaveAllAction saveallaction = new SaveAllAction(intendedreceiver);
ide.SetAction(saveallaction);
ide.ExecuteAction();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

public class IDE {
Action action;
public void SetAction(Action action) {
this.action = action;
}
public void ExecuteAction() {
action.Do();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

public class Receiver {
public void PerformSave() {
System.out.println("Saving file...");
}
public void PerformSaveAll() {
System.out.println("Saving all the files...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

public class SaveAction implements Action{
Receiver receiver;
public SaveAction(Receiver receiver) {
this.receiver = receiver;
}
public void Do() {
receiver.PerformSave();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

public class SaveAllAction implements Action{
Receiver receiver;
public SaveAllAction(Receiver receiver) {
this.receiver = receiver;
}
public void Do() {
receiver.PerformSaveAll();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import java.util.Scanner;

public class WrappingPaperArt {

public static void main(String[] args) {
Object lock = new Object();
Scanner sc = new Scanner(System.in);
System.out.print("Enter Pattern 1 = ");
String pattern1 = sc.next();
System.out.print("Enter Pattern 2 = ");
String pattern2 = sc.next();
System.out.print("Enter count = ");
int count = sc.nextInt();

System.out.println("========Threads start printing patterns.=======");

Thread patternThread1 = new Thread(new Pattern01(lock, pattern1, count));
Thread patternThread2 = new Thread(new Pattern02(lock, pattern2, count));

patternThread1.setName("Pattern 01 Thread");
patternThread2.setName("Pattern 02 Thread");
patternThread1.start();
patternThread2.start();
}
}

class Pattern01 implements Runnable{

Object lock;
String pattern;
int count;

public Pattern01(Object lock, String pattern, int count) {
this.lock = lock;
this.pattern = pattern;
this.count = count;
}

@Override
public void run() {
synchronized (lock) {
for (int x = 0; x < count; x++){
try {
lock.wait();
for (int y = count; y >= x; y--) {
System.out.print(" ");
}
for (int y = 0; y <= x; y++) {
System.out.print("+ ");
}
System.out.println();
Thread.sleep(1000);
lock.notify();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}

class Pattern02 implements Runnable{

Object lock;
String pattern;
int count;

public Pattern02(Object lock, String pattern, int count) {
this.lock = lock;
this.pattern = pattern;
this.count = count;
}

@Override
public void run() {
synchronized (lock) {
for (int x = 0; x < count; x++){
try {
lock.notify();

for (int y = count; y >= x; y--) {
System.out.print(" ");
}
for (int y = 0; y <= x; y++) {
System.out.print("- ");
}
System.out.println();
Thread.sleep(1000);
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}

10 changes: 10 additions & 0 deletions Past Papers/Mock paper Answers-20211018/mock MCQ - answers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1->E
2->C
3->A,C
4->B,C,D,E
5->C
6->E
7->C
8->C
9->B
10->A,B,C,D