Skip to content

Commit

Permalink
Uploaded all exercises completed.
Browse files Browse the repository at this point in the history
Uploaded the entire course. Part I.
  • Loading branch information
ReudyMiguel20 committed Apr 3, 2023
1 parent 5322919 commit e4716a6
Show file tree
Hide file tree
Showing 615 changed files with 10,601 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/part05-Part05_02.Book/target/
/part05-Part05_03.Cube/target/
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion part05-Part05_01.OneMinute/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] args) {
timer.advance();

try {
Thread.sleep(1);
Thread.sleep(10);
} catch (Exception e){

}
Expand Down
27 changes: 27 additions & 0 deletions part05-Part05_02.Book/src/main/java/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Book {
private String author;
private String title;
private int pages;

public Book(String bookAuthor, String bookTitle, int bookPages){
this.author = bookAuthor;
this.title = bookTitle;
this.pages = bookPages;
}

public String getAuthor(){
return this.author;
}

public String getName(){
return this.title;
}

public int getPages(){
return this.pages;
}

public String toString(){
return this.author + ", " + this.title + ", " + this.pages + " pages";
}
}
7 changes: 5 additions & 2 deletions part05-Part05_02.Book/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ public static void main(String[] args) {
// An example that you can use for testing:


// Book b = new Book("J. K. Rowling", "Harry Potter and the Sorcerer's Stone", 223);
// System.out.println(b);
Book b = new Book("J. K. Rowling", "Harry Potter and the Sorcerer's Stone", 223);
System.out.println(b);
System.out.println(b.toString());



}
}
18 changes: 18 additions & 0 deletions part05-Part05_03.Cube/src/main/java/Cube.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class Cube {
private int edgeLength;

public Cube(int edgeLength){
this.edgeLength = edgeLength;
}

public int volume(){
return (edgeLength * edgeLength * edgeLength);
// this.cubeNumber = edgeLength * edgeLength * edgeLength;
// return this.cubeNumber;
}

@Override
public String toString(){
return "The length of the edge is " + this.edgeLength + " and the volume " + volume();
}
}
4 changes: 3 additions & 1 deletion part05-Part05_03.Cube/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Experiment with your program here
Cube cubeOne = new Cube(7);
cubeOne.volume();
System.out.println(cubeOne.toString());
}
}
15 changes: 15 additions & 0 deletions part05-Part05_04.FitByte/src/main/java/Fitbyte.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Fitbyte {
private int age;
private int restingHeartRate;

public Fitbyte(int age, int restingHeartRate){
this.age = age;
this.restingHeartRate = restingHeartRate;
}

public double targetHeartRate(double percentageOfMaximum){
double maximumHeartRate = 206.3 - (0.711 * this.age);
double result = ((maximumHeartRate - this.restingHeartRate) * (percentageOfMaximum) + this.restingHeartRate);
return result;
}
}
18 changes: 9 additions & 9 deletions part05-Part05_04.FitByte/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ public static void main(String[] args) {
// This is an empty main method where you can experiment
// with your Fitbyte class

// Fitbyte fitbyte = new Fitbyte(30, 60);
//
// double percentage = 0.5;
//
// while (percentage < 1.0) {
// double target = fitbyte.targetHeartRate(percentage);
// System.out.println("Target " + (percentage * 100) + "% of maximum: " + target);
// percentage += 0.1;
// }
Fitbyte fitbyte = new Fitbyte(30, 60);

double percentage = 0.5;

while (percentage < 1.0) {
double target = fitbyte.targetHeartRate(percentage);
System.out.println("Target " + (percentage * 100) + "% of maximum: " + target);
percentage += 0.1;
}

}
}
Binary file not shown.
Binary file added part05-Part05_04.FitByte/target/classes/Program.class
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Program.class
Fitbyte.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_04.FitByte\src\main\java\Program.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_04.FitByte\src\main\java\Fitbyte.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FitbyteTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_04.FitByte\src\test\java\FitbyteTest.java
File renamed without changes.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
public class MainProgram {

public static void main(String[] args) {
// Test your class here
Product tapeMeasure = new Product("Tape measure");
Product plaster = new Product("Plaster", "home improvement section");
Product tyre = new Product("Tyre", 5);

System.out.println(tapeMeasure);
System.out.println(plaster);
System.out.println(tyre);
}
}
12 changes: 12 additions & 0 deletions part05-Part05_05.ConstructorOverload/src/main/java/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ public Product(String name, String location, int weight) {
this.location = location;
this.weight = weight;
}

public Product(String name, int weight){
this(name, "shelf", weight);
}

public Product(String name, String location){
this(name, location, 1);
}

public Product(String name){
this(name, "shelf", 1);
}


public String getName() {
return name;
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Product.class
MainProgram.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_05.ConstructorOverload\src\main\java\Product.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_05.ConstructorOverload\src\main\java\MainProgram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ConstructorOverloadTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_05.ConstructorOverload\src\test\java\ConstructorOverloadTest.java
Binary file not shown.
40 changes: 40 additions & 0 deletions part05-Part05_06.OverloadedCounter/src/main/java/Counter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

public class Counter {

private int counter;

public Counter(int startValue) {
this.counter = startValue;
}

public Counter() {
this.counter = 0;
}

public int value() {
return this.counter;
}

public void increase(int increaseBy) {
if (increaseBy > 0) {
this.counter = this.counter + increaseBy;
}
this.counter = this.counter;
}

public void decrease(int decreaseBy) {
if (decreaseBy > 0) {
this.counter = this.counter - decreaseBy;
}
this.counter = this.counter;
}

public void increase() {
this.counter += 1;
}

public void decrease() {
this.counter -= 1;
}

}
16 changes: 16 additions & 0 deletions part05-Part05_06.OverloadedCounter/src/main/java/MainProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,21 @@ public class MainProgram {

public static void main(String[] args) {
// Test your counter here
Counter c = new Counter();
Counter cTwo = new Counter(900);

System.out.println(c.value());
System.out.println(cTwo.value());

c.increase(30);
cTwo.decrease(-55);

System.out.println(c.value());
System.out.println(cTwo.value());

c.increase(-2);

System.out.println(c.value());
System.out.println(cTwo.value());
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MainProgram.class
Counter.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\main\java\MainProgram.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\main\java\Counter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ConstructorSignature.class
MethodSignature.class
Utils.class
CounterTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\test\java\CounterTest.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\test\java\Utils.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\test\java\MethodSignature.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_06.OverloadedCounter\src\test\java\ConstructorSignature.java
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static void main(String[] args) {
lines.add("give up most of his life for physics and research of many hypothesis. But, this is why");
lines.add("you and I have even heard of the quantum theory and atomic structures. Bohr came");
lines.add("up with his quantum theory while studying...");

lines = null;

int index = 0;
while (index < lines.size()) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NullPointerExceptionProgram.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_07.NullPointerException\src\main\java\NullPointerExceptionProgram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NPEErrorTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_07.NullPointerException\src\test\java\NPEErrorTest.java
Binary file not shown.
13 changes: 13 additions & 0 deletions part05-Part05_08.BiggestPetShop/src/main/java/MainProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,18 @@ public static void main(String[] args) {
Person leo = new Person("Leo", hulda);

System.out.println(leo);

Pet terry = new Pet("Terry", "Turtle");
Person mike = new Person("Mike", terry);

System.out.println(mike);

Person p1 = new Person("Odin");

System.out.println(p1);

Person p2 = new Person();

System.out.println(p2);
}
}
2 changes: 1 addition & 1 deletion part05-Part05_08.BiggestPetShop/src/main/java/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Person() {

@Override
public String toString() {
return this.nimi;
return this.name + "," + " has a friend called " + pet.getName() + " (" +pet.getBreed() + ")";
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pet.class
MainProgram.class
Person.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_08.BiggestPetShop\src\main\java\MainProgram.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_08.BiggestPetShop\src\main\java\Person.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_08.BiggestPetShop\src\main\java\Pet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TheBiggestPetShopTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_08.BiggestPetShop\src\test\java\TheBiggestPetShopTest.java
Binary file not shown.
14 changes: 12 additions & 2 deletions part05-Part05_09.HealthStation/src/main/java/HealthStation.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@

public class HealthStation {


private int weighings;

public int weigh(Person person) {
// return the weight of the person passed as the parameter
return -1;
weighings++;
return person.getWeight();
}

public void feed(Person person) {
person.setWeight(person.getWeight() + 1);
}

public int weighings(){
return weighings;
}

}
20 changes: 20 additions & 0 deletions part05-Part05_09.HealthStation/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,25 @@ public class Main {

public static void main(String[] args) {
// write experimental code here to check how your program functions
HealthStation childrensHospital = new HealthStation();

Person ethan = new Person("Ethan", 1, 110, 7);
Person matt = new Person ("Matt", 33, 176, 85);

System.out.println(ethan.getName() + " weight: " + childrensHospital.weigh(ethan) + " kilos");
System.out.println(matt.getName() + " weight: " + childrensHospital.weigh(matt) + " kilos");

System.out.println("weighings performed: " + childrensHospital.weighings());

childrensHospital.weigh(ethan);
childrensHospital.weigh(ethan);
childrensHospital.weigh(ethan);

System.out.println("weighings performed: " + childrensHospital.weighings());

System.out.println("");

System.out.println(ethan.getName() + " weight: " + childrensHospital.weigh(ethan) + " kilos");
System.out.println(matt.getName() + " weight: " + childrensHospital.weigh(matt) + " kilos");
}
}
2 changes: 2 additions & 0 deletions part05-Part05_09.HealthStation/src/main/java/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Person {
private int age;
private int height;
private int weight;


public Person(String name, int age, int height, int weight) {
this.name = name;
Expand Down Expand Up @@ -57,6 +58,7 @@ public double bmi() {
public String getName() {
return this.name;
}


@Override
public String toString() {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Main.class
HealthStation.class
Person.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_09.HealthStation\src\main\java\Main.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_09.HealthStation\src\main\java\Person.java
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_09.HealthStation\src\main\java\HealthStation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HealthStationTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\mikec\OneDrive\Documents\NetBeansProjects\mooc-java-programming-i\part05-Part05_09.HealthStation\src\test\java\HealthStationTest.java
Binary file not shown.
Loading

0 comments on commit e4716a6

Please sign in to comment.