Browse Source

(refactor) Change Section to Exercise

main
Rob Hallam 1 year ago
parent
commit
1052e8e5b6
1 changed files with 28 additions and 25 deletions
  1. +28
    -25
      week1.java

+ 28
- 25
week1.java View File

@@ -10,28 +10,34 @@ class runLabs {
} }
} }


class Section {
private int _sectionNumber;
class Exercise {
private int _exerciseNumber;


public Section(int s) {
this._sectionNumber = s;
this.printSection();
public Exercise(int s) {
this._exerciseNumber = s;
this.printExercise();
} }


public int getSection() {
return _sectionNumber;
}

public void printSection() {
String title = String.format("Starting section %s", this._sectionNumber);
public void printExercise() {
String title = String.format("Starting exercise %s", this._exerciseNumber);


System.out.println("-".repeat(title.length())); System.out.println("-".repeat(title.length()));
System.out.println(String.format("%s", title)); System.out.println(String.format("%s", title));
System.out.println("-".repeat(title.length())); System.out.println("-".repeat(title.length()));
} }

public int get_exerciseNumber() {
return _exerciseNumber;
}

public void set_exerciseNumber(int _exerciseNumber) {
this._exerciseNumber = _exerciseNumber;
}
} }


class Lab { class Lab {
private int _labNumber;
public Exercise currentExercise;


public Lab(int lN) { public Lab(int lN) {
String title = String.format("|Starting Lab %s|", lN); String title = String.format("|Starting Lab %s|", lN);
@@ -42,19 +48,16 @@ class Lab {
System.out.println("*".repeat(title.length())); System.out.println("*".repeat(title.length()));
} }


private int _labNumber;
public Section currentSection;

public Section getCurrentSection() {
return currentSection;
public Exercise getCurrentExercise() {
return currentExercise;
} }


public void setCurrentSection(Section currentSection) {
this.currentSection = currentSection;
public void setCurrentExercise(Exercise currentSection) {
this.currentExercise = currentSection;
} }


public static void printSection(String section) { public static void printSection(String section) {
String title = String.format("Starting section %s", section);
String title = String.format("Starting exercise %s", section);


System.out.println("-".repeat(title.length())); System.out.println("-".repeat(title.length()));
System.out.println(String.format("%s", title)); System.out.println(String.format("%s", title));
@@ -220,7 +223,7 @@ class Lab5 extends Lab {
new five1(); new five1();
} }


class five1 extends Section {
class five1 extends Exercise {
/** /**
* We will now look at how we can get user input from the keyboard. We will * We will now look at how we can get user input from the keyboard. We will
* gloss over some * gloss over some
@@ -257,7 +260,7 @@ class Lab6 extends Lab {
/** /**
* Times tables * Times tables
*/ */
class six1 extends Section {
class six1 extends Exercise {
public six1() { public six1() {
super(1); super(1);
int testNum = 6; int testNum = 6;
@@ -266,7 +269,7 @@ class Lab6 extends Lab {
} }
} }


class six3 extends Section {
class six3 extends Exercise {
public six3() { public six3() {
super(3); super(3);
int testNum = 13; // statistically the most prime of all numbers int testNum = 13; // statistically the most prime of all numbers
@@ -282,7 +285,7 @@ class Lab6 extends Lab {
} }
} }


class six5 extends Section {
class six5 extends Exercise {
public six5() { public six5() {
super(5); super(5);
System.out.println(String.format("TODO / NOT IMPLEMENTED until we get stdin working")); System.out.println(String.format("TODO / NOT IMPLEMENTED until we get stdin working"));
@@ -297,7 +300,7 @@ class Lab6 extends Lab {
* 3 3 3 * 3 3 3
* 4 4 4 4 * 4 4 4 4
*/ */
class six6 extends Section {
class six6 extends Exercise {
public six6() { public six6() {
super(6); super(6);
numberTriangle(1); numberTriangle(1);
@@ -307,7 +310,7 @@ class Lab6 extends Lab {
} }
} }


class six7 extends Section {
class six7 extends Exercise {
public six7() { public six7() {
super(7); super(7);
describeDD(4.2, 1.6); describeDD(4.2, 1.6);


Loading…
Cancel
Save