Merge pull request #25 from TiagoRG/dev-tiagorg

LSD material and POO refactoring
This commit is contained in:
Tiago Garcia 2023-02-25 18:00:22 +00:00 committed by GitHub
commit fa409046bd
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
11 changed files with 46 additions and 31 deletions

Binary file not shown.

View File

@ -0,0 +1,9 @@
# Laboratórios de Sistemas Digitais
## Trabalho prático 02
### Tópico principal da aula: Modelação em VHDL, simulação e implementação de componentes combinatórios
* [Slides](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/lsd/slides/LSD_2022-23_AulaTP02.pdf)
* [Guião](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/lsd/aula02/LSD_2022-23_TrabPrat02.pdf)
---
*Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new)

Binary file not shown.

View File

@ -0,0 +1,9 @@
# Laboratórios de Sistemas Digitais
## Trabalho prático 03
### Tópico principal da aula: Modelação em VHDL e implementação de circuitos aritméticos
* [Slides](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/lsd/slides/LSD_2022-23_AulaTP03.pdf)
* [Guião](https://github.com/TiagoRG/uaveiro-leci/blob/master/1ano/2semestre/lsd/aula03/LSD_2022-23_TrabPrat03-1.pdf)
---
*Pode conter erros, caso encontre algum, crie um* [*ticket*](https://github.com/TiagoRG/uaveiro-leci/issues/new)

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -45,7 +45,7 @@ public class Calendar {
} }
private static void printCalendar(int[] data, int monthDays) { private static void printCalendar(int[] data, int monthDays) {
System.out.printf("\n%13s %d\n", monthName(data[0]), data[1]); System.out.printf("\n%15s %d\n", monthName(data[0]), data[1]);
System.out.println("Dom Seg Ter Qua Qui Sex Sab"); System.out.println("Dom Seg Ter Qua Qui Sex Sab");
if (data[2] != 7) if (data[2] != 7)

View File

@ -31,16 +31,16 @@ public class Grades {
System.out.printf("%5.1f %5.1f %5d\n", student.notaT, student.notaP, student.notaFinal); System.out.printf("%5.1f %5.1f %5d\n", student.notaT, student.notaP, student.notaFinal);
} }
} }
}
class Student { private static class Student {
public double notaT; public double notaT;
public double notaP; public double notaP;
public int notaFinal; public int notaFinal;
public Student(double notaT, double notaP) { public Student(double notaT, double notaP) {
this.notaT = notaT; this.notaT = notaT;
this.notaP = notaP; this.notaP = notaP;
this.notaFinal = (notaT < 7 || notaP < 7) ? 66 : (int) Math.round(0.4 * notaT + 0.6 * notaP); this.notaFinal = (notaT < 7 || notaP < 7) ? 66 : (int) Math.round(0.4 * notaT + 0.6 * notaP);
}
} }
} }

View File

@ -1,5 +1,6 @@
package aula03; package aula03;
import utils.MathTools;
import utils.UserInput; import utils.UserInput;
import java.util.Scanner; import java.util.Scanner;
@ -14,20 +15,11 @@ public class PrimesSum {
int sum = 0; int sum = 0;
for (int i = 0; i <= n; i++) for (int i = 0; i <= n; i++)
if (isNumPrime(i)) if (MathTools.isNumPrime(i))
sum += i; sum += i;
System.out.printf("A soma dos números primos até %d é %d\n", n, sum); System.out.printf("A soma dos números primos até %d é %d\n", n, sum);
sin.close(); sin.close();
} }
private static boolean isNumPrime(int n) {
if (n == 1)
return false;
for (int i = 2; i < n; i++)
if (n % i == 0)
return false;
return true;
}
} }

View File

@ -1,7 +1,23 @@
package utils; package utils;
import java.util.Random;
public class MathTools { public class MathTools {
public static double round(double n, int places) { public static double round(double n, int places) {
return (Math.round(n * Math.pow(10, places))) / Math.pow(10, places); return (Math.round(n * Math.pow(10, places))) / Math.pow(10, places);
} }
public static double random(double minLimit, double maxLimit) {
Random rand = new Random();
return rand.nextDouble(minLimit, maxLimit);
}
public static boolean isNumPrime(int n) {
if (n <= 1)
return false;
for (int i = 2; i < n; i++)
if (n % i == 0)
return false;
return true;
}
} }