From 75c65baa409a57f780f8842696aa8ede679a2dda Mon Sep 17 00:00:00 2001 From: Luis Carlos Eich Date: Wed, 6 Jan 2021 14:30:57 -0300 Subject: [PATCH 1/2] First version --- .idea/.gitignore | 3 + .idea/aws.xml | 11 + .idea/dbnavigator.xml | 461 ++++++++++++++++++++++ .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/uiDesigner.xml | 124 ++++++ .idea/vcs.xml | 6 + curso_programacao.iml | 11 + src/Funcoes.java | 333 ++++++++++++++++ src/application/Program.java | 567 ++++++++++++++++++++++++++++ src/entities/Account.java | 46 +++ src/entities/CurrencyConverter.java | 11 + src/entities/Employee.java | 54 +++ src/entities/Product.java | 61 +++ src/entities/Rectangle.java | 22 ++ src/entities/Room.java | 30 ++ src/entities/Triangle.java | 13 + src/util/Calculator.java | 12 + 18 files changed, 1779 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/aws.xml create mode 100644 .idea/dbnavigator.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 curso_programacao.iml create mode 100644 src/Funcoes.java create mode 100644 src/application/Program.java create mode 100644 src/entities/Account.java create mode 100644 src/entities/CurrencyConverter.java create mode 100644 src/entities/Employee.java create mode 100644 src/entities/Product.java create mode 100644 src/entities/Rectangle.java create mode 100644 src/entities/Room.java create mode 100644 src/entities/Triangle.java create mode 100644 src/util/Calculator.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml new file mode 100644 index 0000000..b79a7ee --- /dev/null +++ b/.idea/dbnavigator.xml @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e0844bc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bb6edb2 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/curso_programacao.iml b/curso_programacao.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/curso_programacao.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Funcoes.java b/src/Funcoes.java new file mode 100644 index 0000000..5e8e180 --- /dev/null +++ b/src/Funcoes.java @@ -0,0 +1,333 @@ +import java.util.Locale; +import java.util.Scanner; + +public class Funcoes { + + + public static void trabalhandoComString(){ + String original = "acdef FGHY ABC abc DEFG "; + log("Original: -"+original+"-"); + String s01 = original.toLowerCase(); + log("lowecase-"+s01+"-"); + String s02 = original.toUpperCase(); + log("UPPERCASE-"+s02+"-"); + String s03 = original.trim(); + log("Trim:-"+s03+"-"); + String s04 = original.substring(2); + log("Substring:-"+s04+"-"); + String s05 = original.substring(2,9); + log("Substring - 2/9:-"+s05+"-"); + String s06 = original.replace("a","x"); + log("replace:-"+s06+"-"); + String s07 = original.replace("abc","xyz"); + log("replace:-"+s07+"-"); + int i = original.indexOf("bc"); + log("Posição:"+i); + int j = original.lastIndexOf("bc"); + log("Ultima Posição:"+j); + + String[] vect = original.split(" "); + log("Tamanho do vetor:"+vect.length); + log("Valor 1 do vetor: "+vect[0]); + + + + + + } + + public static void repeticaoDoWhile(){ + Scanner sc = new Scanner(System.in); + char repetir; + do{ + log("Informe a temperatura em Celsius: "); + double celsius = sc.nextDouble(); + double fahrenheit = (9 * celsius / 5) + 32; + log("Temperatura em Fahrenheit: "+fahrenheit); + log("Repetir (s/n)?"); + repetir = sc.next().charAt(0); + }while( repetir != 'n'); + } + + public static void repeticaoFor(){ + Scanner sc = new Scanner(System.in); + log("Informe o número de valores: "); + int N = sc.nextInt(); + int soma = 0; + for(int i = 0; i < N;i++){ + log("Informe o valor "+(i+1)+" de " +N); + + soma += sc.nextInt(); + } + log("Soma: "+soma); + + sc.close(); + } + + public static void repeticaoWhile(){ + Scanner sc = new Scanner(System.in); + int soma = 0; + log("Informe o valor: "); + int x =sc.nextInt(); + while( x != 0){ + soma += x; + log("Informe o valor: "); + x = sc.nextInt(); + } + + log("Soma dos valores: "+soma); + sc.close(); + + + } + + + + public static void condicaoTernaria(){ + double preco = 34.5; + double desconto = (preco<20.0)?preco*0.1:preco*0.05; + log(preco+" - Desconto: "+desconto); + + } + + public static void diaSemana(){ + Scanner sc = new Scanner(System.in); + log("Informe o dia da semana:"); + int diaSemana = sc.nextInt(); + String dia; + switch (diaSemana){ + case 1: + dia = "Domingo"; + break; + case 2: + dia = "Segunda"; + break; + case 3: + dia = "Terça"; + break; + case 4: + dia = "Quarta"; + break; + case 5: + dia = "Quinta"; + break; + case 6: + dia = "Sexta"; + break; + case 7: + dia = "Sábado"; + break; + default: + dia = "Valor inválido"; + } + log("Dia da Semana: "+dia); + sc.close(); + + } + + public static void minutosOperadora(){ + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + log("Informe os minutos: "); + int minutos = sc.nextInt(); + int franquia = 100; + double valorplano = 50.0; + double valorporminuto = 2.0; + if(minutos > franquia){ + valorplano += ((minutos - franquia) * valorporminuto); + } + System.out.printf("Valor da fatura: %.2f%n",valorplano); + + } + + public static void estruturaCondicional(){ + Scanner sc = new Scanner(System.in); + + log("Qual o horário?"); + int hora = sc.nextInt(); + + + if(hora<12){ + log("Bom dia"); + + }else if(hora < 18){ + log("Boa tarde!"); + //log("Boa noite"); + }else{ + log("Boa noite"); + } + + } + public static void log(String msg){ + System.out.println(msg); + } + public static void conteudoaula(){ + Scanner sc = new Scanner(System.in); + /* + char x; + x = sc.next().charAt(0); + log(x+""); + + int y = sc.nextInt(); + log("Você digitou:"+y); + */ + + /* + //Locale.setDefault(Locale.US); + log("Hello World"); + int idade = 25; + double altura = 1.68123121; + char sexo = 'F'; + System.out.printf("%.2f%n",altura); + System.out.printf("%.4f%n",altura); + + log(altura+""); + + System.out.printf("Resultado %.2f metros%n",altura); + String nome = "Luis"; + Double salario = 4000.00; + System.out.printf("%s tem %d anos e ganha R$ %.2f reais%n",nome, idade, salario); + + + log(idade+" " + altura+ " "+sexo); + + String product1 = "Computer"; + String product2 = "Office desk"; + + int age = 30; + int code = 5290; + char gender = 'F'; + + double price1 = 2100.0; + double price2 = 650.5; + double measure = 53.234567; + Locale.setDefault(Locale.getDefault()); + System.out.printf("Products%n" + + "%s which price is $ %.2f%n" + + "%s which price is $ %.2f%n%n" + + "Record %d years old, code %d and gender: %s %n" + + "Measure with eight decimal places: %.8f %n" + + "Rounded (three decimal places): %.3f %n",product1,price1,product2, price2,age,code,gender,measure,measure); + Locale.setDefault(Locale.US); + System.out.printf("US Decimal point %.3f",measure); + + */ + + } + public static void ex01(){ + Scanner sc = new Scanner(System.in); + + + //sc.close(); + int a = 0; + int b = 0; + + a = sc.nextInt(); + b = sc.nextInt(); + + log("Soma: "+(a+b)); + + } + + public static void ex02(){ + Scanner sc = new Scanner(System.in); + double pi = 3.14159; + + double area = sc.nextDouble(); + System.out.printf("Área: %.4f%n",(pi*(area*area ))); + + } + + public static void ex03(){ + Scanner sc = new Scanner(System.in); + + int a, b, c, d; + + a = sc.nextInt(); + b = sc.nextInt(); + c = sc.nextInt(); + d = sc.nextInt(); + int diferenca = (a*b - c*d); + log("Diferença: "+diferenca); + } + + + public static void ex04(){ + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int matricula = sc.nextInt(); + int horastrabalhadas = sc.nextInt(); + double valorporhora = sc.nextDouble(); + + log("Number = "+matricula); + System.out.printf("SALARY = %.2f%n",(double)horastrabalhadas * valorporhora); + + } + + public static void ex05(){ + + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int cod1 = sc.nextInt(); + int qtde1 = sc.nextInt(); + double vlr1 = sc.nextDouble(); + + int cod2 = sc.nextInt(); + int qtde2 = sc.nextInt(); + double vlr2 = sc.nextDouble(); + + double total = (qtde1 * vlr1) + (qtde2 * vlr2); + System.out.printf("VALOR A PAGAR: R$ %.2f%n",total); + + } + + public static void ex06(){ + log("Informe 3 valores A, B, C"); + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + double a = sc.nextDouble(); + double b = sc.nextDouble(); + double c = sc.nextDouble(); + double pi = 3.14159; + System.out.printf("Área do triangulo Base A, Altura C: %.3f%n",a*c/2); + System.out.printf("Área do Círculo: %.3f%n",(pi*(c*c))); + System.out.printf("Área do trapézio: %.3f%n",((a+b)*c)/2); + System.out.printf("QUADRADO: %.3f%n",b*b); + System.out.printf("RETANGULO: %.3f%n",a*b); + + + } + + public static void raizQuadrada(){ + double y = 25.0; + double x = Math.sqrt(y); + Funcoes.log(""+x); + } + + public static void maiorValor(){ + Scanner sc = new Scanner(System.in); + Funcoes.log("Informe 3 valores"); + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + Funcoes.log("Maior Valor: "+max(a,b,c)+""); + + sc.close(); + + } + + public static int max(int x,int y, int z){ + int aux = 0; + if(x > y & x > z){ + aux = x; + }else if(y>z){ + aux = y; + }else{ + aux = z; + } + + + return aux; + } + +} diff --git a/src/application/Program.java b/src/application/Program.java new file mode 100644 index 0000000..6c4a9fc --- /dev/null +++ b/src/application/Program.java @@ -0,0 +1,567 @@ +package application; + +import entities.*; +import entities.CurrencyConverter; +import entities.Product; +import entities.Triangle; +import util.Calculator; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.util.*; +import java.util.stream.Collectors; + +public class Program { + + + public static void main(String[] args) throws ParseException { + //movimentaItem(); + //compraDolar(); + //abreConta(); + + //vetorParte1(); + //vetorParte2(); + //exercicioVetor(); + //lacoForEach(); + //listasParte(); + //exercicioFuncionarios(); + //matriz(); + //matriz2(); + + //dataJava1(); + dataJava2(); + + + + } + + public static void dataJava2(){ + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + Date d = Date.from(Instant.parse("2018-06-25T15:42:07Z")); + System.out.println(sdf.format(d)); + Calendar cal = Calendar.getInstance(); + cal.setTime(d); + cal.add(Calendar.HOUR_OF_DAY,4 ); + d = cal.getTime(); + System.out.println(sdf.format(d)); + int minutes = cal.get(Calendar.MINUTE); + System.out.println("Minutes: "+minutes); + int month = 1+cal.get(Calendar.MONTH); + System.out.println("Month: "+month); + + } + + + public static void dataJava1() throws ParseException { + SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy"); + SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + SimpleDateFormat sdf3 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); + sdf3.setTimeZone(TimeZone.getTimeZone("GMT")); + + Date x1 = new Date(); + Date x2 = new Date(System.currentTimeMillis()); + Date x3 = new Date(0L); + Date x4 = new Date(1000 * 60 * 60 * 5); + + Date y1 = sdf1.parse("25/06/2018"); + Date y2 = sdf2.parse("25/06/2018 15:42:07"); + Date y3 = Date.from(Instant.parse("2018-06-25T15:42:07Z")); + //System.out.println(y1 + " - "+y2); + + System.out.println("x1: "+(x1)); + System.out.println("x2: "+(x2)); + System.out.println("x3: "+(x3)); + System.out.println("x4: "+(x4)); + System.out.println("y1: "+(y1)); + System.out.println("y2: "+(y2)); + System.out.println("y3: "+(y3)); + System.out.println("---------------------------------------"); + System.out.println("x1: "+sdf2.format(x1)); + System.out.println("x2: "+sdf2.format(x2)); + System.out.println("x3: "+sdf2.format(x3)); + System.out.println("x4: "+sdf2.format(x4)); + System.out.println("y1: "+sdf2.format(y1)); + System.out.println("y2: "+sdf2.format(y2)); + System.out.println("y3: "+sdf2.format(y3)); + System.out.println("---------------------------------------"); + System.out.println("x1: "+sdf3.format(x1)); + System.out.println("x2: "+sdf3.format(x2)); + System.out.println("x3: "+sdf3.format(x3)); + System.out.println("x4: "+sdf3.format(x4)); + System.out.println("y1: "+sdf3.format(y1)); + System.out.println("y2: "+sdf3.format(y2)); + System.out.println("y3: "+sdf3.format(y3)); + + + } + + +// 3 4 10 8 15 12 21 11 23 8 14 5 13 19 8 + public static void matriz2(){ + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + int M, N; + + System.out.print("Linhas: "); + M = sc.nextInt(); + System.out.print("Colunas: "); + N = sc.nextInt(); + + System.out.println("Linhas: "+M+" - Colunas: "+N); + int [][] mat = new int[M][N]; + for (int i = 0; i< mat.length ;i++){ + for(int j = 0; j < mat[i].length ;j++){ + System.out.print("Posição "+i+"-"+j+": "); + mat[i][j] = sc.nextInt(); + } + } + System.out.print("Insert the value to find position:"); + System.out.println(""); + int valor = sc.nextInt(); + for (int i = 0; i< mat.length ;i++){ + for(int j = 0; j < mat[i].length ;j++){ + if(valor == mat[i][j]){ + System.out.println("--------------------"); + System.out.println("Position "+i+","+j); + //mostrar os outros valores... + + if(j>0){ + System.out.print("Value LEFT: "); + System.out.println(mat[i][j-1]); + } + if(j < mat[i].length-1){ + System.out.print("Value RIGHT: "); + System.out.println(mat[i][j+1]); + } + if(i>0){ + System.out.print("Value UP: "); + System.out.println(mat[i-1][j]); + } + if(i < mat.length -1){ + System.out.print("Value DOWN: "); + System.out.println(mat[i+1][j]); + } + + + } + } + } + +// 3 4 10 8 15 12 21 11 23 8 14 5 13 19 8 + + + sc.close(); + } + + + public static void matriz(){ + //vetor: 5 -3 10 15 8 2 7 9 -4 + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + System.out.print("Matriz bidimensional de tamanho: "); + int n = sc.nextInt(); + int [][] mat = new int[n][n]; + + for (int i = 0; i< mat.length ;i++){ + for(int j = 0; j < mat[i].length ;j++){ + System.out.print("Posição "+i+"-"+j+": "); + mat[i][j] = sc.nextInt(); + } + } + + + System.out.println(""); + System.out.println("Diagonal Principal"); + for (int i = 0; i list = new ArrayList<>(); + for (int i = 0;i < n;i++){ + + System.out.println("Employe #"+(i+1)+": "); + System.out.print("ID: "); + int id = sc.nextInt(); + //validate if id is in use.... + while (hasId(list, id)) { + System.out.print("Id already taken! Try again: "); + id = sc.nextInt(); + } + + System.out.print("Name: "); + sc.nextLine(); + String name = sc.nextLine(); + System.out.print("Salary: "); + double salary = sc.nextDouble(); + + list.add(new Employee(id,name,salary)); + + } + + System.out.print("Enter the employee id that will have salary increase: "); + int idsalary = sc.nextInt(); + while (!hasId(list, idsalary)) { + System.out.print("ID don't located. Try Again"); + idsalary = sc.nextInt(); + } + System.out.print("Enter the percentage: "); + double percentage = sc.nextDouble(); + + int finalIdsalary = idsalary; + Employee emp = list.stream().filter(x -> x.getId() == finalIdsalary).findFirst().orElse(null); + emp.increaseSalary(percentage); + System.out.println(emp.getName()+" - New Salary: "+emp.getSalary()); + + + System.out.println("List of employees:"); + for (Employee e : list) { + System.out.println(e); + } + + } + + public static boolean hasId(List list, int id) { + Employee emp = list.stream().filter(x -> x.getId() == id).findFirst().orElse(null); + return emp != null; + } + + public static void listasParte(){ + List list = new ArrayList<>(); + + list.add("Maria"); + list.add("John"); + list.add("Bob"); + list.add("Alex"); + list.add(2,"Luis"); + + System.out.println(list.size()); + for (String x : list){ + System.out.println(x); + } + System.out.println("---------------"); + //list.removeIf(x -> x.charAt(0) == 'M'); + for (String x : list){ + System.out.println(x); + } + System.out.println("---------------"); + System.out.println("Index of Bob: "+ list.indexOf("Bob")); + List result = list.stream().filter(x -> x.charAt(0) == 'M').collect(Collectors.toList()); + for (String x : result){ + System.out.println(x); + } + + System.out.println("---------------"); + String name = list.stream().filter(x->x.charAt(0)=='A').findFirst().orElse(null); + System.out.println(name ); + + + + + } + + public static void lacoForEach(){ + String[] vect = new String[]{"Maria","Bob","Alex"}; + for (int i = 0;i Número do Quarto:"); + int nroquarto = sc.nextInt(); + System.out.println("Name: "); + String name = sc.next(); + System.out.println("Email:"); + String email = sc.next(); + rooms[nroquarto] = new Room(name, email); + + } + + System.out.println("Busy Rooms:"); + for(int i = 0;i < 10;i++){ + + if( rooms[i] != null){ + + System.out.println(i+": "+rooms[i].getName()+", "+rooms[i].getEmail()); + } + + } + + + } + + public static void vetorParte2(){ + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + System.out.print("Número de registros: "); + int n = sc.nextInt(); + Product[] products = new Product[n]; + for (int i = 0;i < products.length; i++){ + System.out.print("-> Informe a descrição para o produto "+(i+1)+": "); + String name = sc.next(); + System.out.print("-> Informe o Preço para o produto "+name+": "); + double price = sc.nextDouble(); + + + Product product = new Product(name, price); + products[i] = product; + + } + + double sum = 0.0; + for (int i = 0;i < products.length; i++){ + sum += products[i].getPrice(); + + + } + double media = sum / products.length; + System.out.println("Média dos valores: "+String.format("%.2f",media)); + + + + sc.close(); + } + + + public static void vetorParte1(){ + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + System.out.print("Número de registros: "); + int n = sc.nextInt(); + double[] vect = new double[n]; + for (int i = 0 ;i < n;i++){ + System.out.print("-> Informe a altura da "+(i+1)+ " pessoa: "); + vect[i] = sc.nextDouble(); + } + + double sum = 0.0; + + for (int i = 0;i areaY){ + System.out.println("Maior área é de X"); + }else{ + System.out.println("Maior área é de Y"); + } + + sc.close(); + + + } + + + public static void triangulo(){ + + Locale.setDefault(Locale.US); + Scanner sc = new Scanner(System.in); + double xA, xB, xC, yA, yB, yC; + System.out.println("Enter the measure of triangle X:"); + xA = sc.nextDouble(); + xB = sc.nextDouble(); + xC = sc.nextDouble(); + + System.out.println("Enter the measure of triangle Y:"); + yA = sc.nextDouble(); + yB = sc.nextDouble(); + yC = sc.nextDouble(); + + double p = (xA + xB + xC) / 2.0; + double areaX = Math.sqrt(p * (p - xA) * (p - xB) * (p - xC )); + + p = (yA + yB + yC) / 2.0; + double areaY = Math.sqrt(p * (p - yA) * (p - yB) * (p - yC )); + + System.out.printf("Triangle X area = %.4f%n",areaX); + System.out.printf("Triangle Y area = %.4f%n",areaY); + + if(areaX > areaY){ + System.out.println("Maior área é de X"); + }else{ + System.out.println("Maior área é de Y"); + } + + sc.close(); + } + +} diff --git a/src/entities/Account.java b/src/entities/Account.java new file mode 100644 index 0000000..998823d --- /dev/null +++ b/src/entities/Account.java @@ -0,0 +1,46 @@ +package entities; + +public class Account { + + private int number; + private String holder; + private double value; + + public Account(int number, String holder) { + this.number = number; + this.holder = holder; + } + + public int getNumber() { + return number; + } + + public String getHolder() { + return holder; + } + + public void setHolder(String holder) { + this.holder = holder; + } + + public double getValue() { + return value; + } + + + + public void deposit(double value){ + System.out.println(" Updated account (+) "+String.format("%.2f",value)); + this.value += value; + } + + public void withdraw(double value){ + double tax = 5.0; + System.out.println(" Updated account (-) "+String.format("%.2f",value)); + this.value -= (value + tax); + } + + public String toString(){ + return "Account "+this.number+", Holder: "+this.holder+", Balance: $ "+String.format("%.2f",this.value); + } +} diff --git a/src/entities/CurrencyConverter.java b/src/entities/CurrencyConverter.java new file mode 100644 index 0000000..315112a --- /dev/null +++ b/src/entities/CurrencyConverter.java @@ -0,0 +1,11 @@ +package entities; + +public class CurrencyConverter { + public double dollarPrice; + public double ammount; + + public double valueInReals(){ + double valor = dollarPrice * ammount; + return valor + (valor * 6 / 100); + } +} diff --git a/src/entities/Employee.java b/src/entities/Employee.java new file mode 100644 index 0000000..89fca20 --- /dev/null +++ b/src/entities/Employee.java @@ -0,0 +1,54 @@ +package entities; + +public class Employee { + private int id; + private String name; + private double salary; + private double tax; + + public Employee(Integer id, String name, double salary) { + this.id = id; + this.name = name; + this.salary = salary; + } + + public Integer getId() { + return id; + } + + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSalary() { + return salary; + } + + + public double getTax() { + return tax; + } + + public void setTax(double tax) { + this.tax = tax; + } + + public double netSalary(){ + return salary - tax; + } + + public void increaseSalary(double percentage){ + salary += (salary * (percentage /100) ); + } + + public String toString(){ + return id + ", " + name + ", " + String.format("%.2f", salary); + } + +} diff --git a/src/entities/Product.java b/src/entities/Product.java new file mode 100644 index 0000000..6430f96 --- /dev/null +++ b/src/entities/Product.java @@ -0,0 +1,61 @@ +package entities; + +public class Product { + private String name; + private double price; + private int quantitity; + + public Product() { + } + + public Product(String name, double price, int quantitity) { + this.name = name; + this.price = price; + this.quantitity = quantitity; + } + + public Product(String name, double price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public int getQuantitity() { + return quantitity; + } + + + public double totalValueInStock(){ + + return price * quantitity; + } + + public void addProducts(int quantitity){ + this.quantitity += quantitity; + } + + public void removeProducts(int quantitity){ + this.quantitity -= quantitity; + } + + public String toString(){ + return "Product data: "+ name + + ", $ "+String.format("%.2f", price)+" , "+quantitity+" units, Total $ "+String.format("%.2f", totalValueInStock()); + } + +} diff --git a/src/entities/Rectangle.java b/src/entities/Rectangle.java new file mode 100644 index 0000000..e4c8dc5 --- /dev/null +++ b/src/entities/Rectangle.java @@ -0,0 +1,22 @@ +package entities; + +public class Rectangle { + + public double width; + public double height; + + public double area(){ + return width * height; + } + + public double permiter(){ + + return 0.0; + } + + public double diagonal(){ + + return 0.0; + } + +} diff --git a/src/entities/Room.java b/src/entities/Room.java new file mode 100644 index 0000000..2c1a193 --- /dev/null +++ b/src/entities/Room.java @@ -0,0 +1,30 @@ +package entities; + +public class Room { + + + private String name; + private String email; + + public Room( String name, String email) { + this.name = name; + this.email = email; + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/src/entities/Triangle.java b/src/entities/Triangle.java new file mode 100644 index 0000000..c30ca43 --- /dev/null +++ b/src/entities/Triangle.java @@ -0,0 +1,13 @@ +package entities; + +public class Triangle { + public double a; + public double b; + public double c; + + public double area(){ + double p = ( a + b + c) / 2.0; + return Math.sqrt(p * (p - a) * (p - b) * (p - c)); + + } +} diff --git a/src/util/Calculator.java b/src/util/Calculator.java new file mode 100644 index 0000000..fa9b81a --- /dev/null +++ b/src/util/Calculator.java @@ -0,0 +1,12 @@ +package util; + +public class Calculator { + public static final double PI = 3.14159; + + public static double circumference(double radius){ + return 2.0 * PI * radius; + } + public static double volume(double radius){ + return 4 * PI * radius * radius * radius / 3.0; + } +} From 0e2efa94843b9bdf672e77f6741491634d62e586 Mon Sep 17 00:00:00 2001 From: Luis Carlos Eich Date: Wed, 6 Jan 2021 14:42:55 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Novo=20m=C3=A9todo=20criado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/application/Program.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/application/Program.java b/src/application/Program.java index 6c4a9fc..0ab1d3e 100644 --- a/src/application/Program.java +++ b/src/application/Program.java @@ -30,10 +30,16 @@ public static void main(String[] args) throws ParseException { //matriz2(); //dataJava1(); - dataJava2(); + //dataJava2(); + testeGitHub(); + + } + + public static void testeGitHub(){ + System.out.println("Log"); } public static void dataJava2(){