From c3a7f964fe5482f75a5990ea6d5b0cfea257e0b2 Mon Sep 17 00:00:00 2001 From: Edu Date: Sun, 25 Oct 2020 19:34:14 -0300 Subject: [PATCH 1/5] program added --- Java/program-7/README.md | 5 ++ Java/program-7/program.java | 150 ++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 Java/program-7/README.md create mode 100644 Java/program-7/program.java diff --git a/Java/program-7/README.md b/Java/program-7/README.md new file mode 100644 index 00000000..d14f17cb --- /dev/null +++ b/Java/program-7/README.md @@ -0,0 +1,5 @@ +Program 7 + +write a program that mixes a deck of cards in spanish. + +Variable description is in the code diff --git a/Java/program-7/program.java b/Java/program-7/program.java new file mode 100644 index 00000000..d4e1d894 --- /dev/null +++ b/Java/program-7/program.java @@ -0,0 +1,150 @@ + +/* write a program that mixes a deck of cards*/ + +// start writng code from here +import java.util.Scanner; + +public class Program +{ + public static void main(String[] args) { + int op,ver=0; + Scanner teclado = new Scanner(System.in); + + //arrays for the Spanish deck + String [] palo_esp = new String [] {"Espada","Copa","Oro","Basto"}; + String [] num_esp = new String[] {"Uno","Dos","Tres","Cuatro","Cinco","Seis","Siete","Ocho","Nueve","Diez","Once","Doce"}; + + //arrays for the French deck + String [] palo_fra = new String [] {"Pica","Trebol","Diamante","Corazones"}; + String [] num_fra = new String[] {"As","Dos","Tres","Cuatro","Cinco","Seis","Siete","Ocho","Nueve","Diez","J","Q","K"}; + + + //I ask the user to choose the type of deck + System.out.println("Que baraja desea crear ? \n"); + System.out.println("1. baraja espaniola "); + System.out.println("2. baraja francesa "); + System.out.println("ingrese numero: "); + op = teclado.nextInt(); + + //I verify the user's choice and print + + if (op == 1) { + + //I create the deck_esp object + Mazo baraja_esp = new Mazo(palo_esp,num_esp); + System.out.println("Baraja lista"); + + System.out.println("Quiere verla ? "); + System.out.println("1.SI 2.NO "); + System.out.println("ingrese numero: "); + ver = teclado.nextInt(); + if(ver == 1) { + //I ask him to show me the deck + baraja_esp.mostrar(); + } + else{ + System.out.print("Chau !!!"); + } + + } + else if (op == 2) { + + + // I create the deck_frame object, I pass the number and suit to the constructor + Mazo baraja_fra = new Mazo(palo_fra,num_fra); + + + System.out.println("Baraja lista"); + + System.out.println("Quiere verla ? "); + System.out.println("1.SI 2.NO "); + System.out.print("ingrese numero: "); + ver = teclado.nextInt(); + if(ver == 1) { + + //I ask him to show me the deck + baraja_fra.mostrar(); + } + else{ + System.out.print("Chau !!!"); + } + } + else { + System.out.println("Error opcion no valida !!!"); + } + } +} + +public class Carta { + private String num;// number of the card + private String palo;// card suit + + //constructor + public Carta(String num,String palo) { + this.num = num; + this.palo = palo; + } + + public String getnum() { + return num; + } + public String getpalo() { + return palo; + } + +} + +public class Mazo { + Carta [] mazo; // array that will contain the cards + private int cant_palo;// number of suit + private int cant_num; // number of number + private int total; // total cards + + + + + // Constructor that receives the suits and the numbers + public Mazo (String []palo, String [] num) { + + cant_palo = palo.length; // I save the length of the array "palo" + cant_num = num.length; //I save the length of the array "num" + total = cant_palo * cant_num; //I calculate the total of cards + mazo = new Carta [total]; //I create the array of objects of type Carta + + llenar(palo,num); //I invoke the method to fill the array "mazo" + } + + + + private void llenar (String []palo, String [] num) { + int h=0;//is to move in the "mazo" + int i;//is to move in the "palo" + int j;//is to move in the "num" + + //I move in the arrays "num", "palo" and "mazo" to create the cards + for(i=0 ; i < cant_palo ; i++) { + + for(j=0; j < cant_num && h< total ;j++,h++) { + + //voy creando cartas con sus correspondientes atributos + // y la direcciones las guardo en el array "mazo" una x una + this.mazo[h] = new Carta(num[j],palo[i]); + } + } + } + + //method to show the cards + public void mostrar () { + int i; + for(i=0 ; i < total; i++) { + + System.out.println("------------------"); + System.out.println("|Carta "+(i+1)); + System.out.println("|palo "+mazo[i].getpalo()); + System.out.println("|num "+mazo[i].getnum()); + System.out.println("------------------"); + System.out.println("\n"); + } + } +} + From b95b7b32d112603333e4fe4492f26ed0f2fdae35 Mon Sep 17 00:00:00 2001 From: Dharmaksha <68665143+Dharmaksha@users.noreply.github.com> Date: Tue, 27 Oct 2020 22:40:26 +0530 Subject: [PATCH 2/5] Update README.md --- C++/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/C++/README.md b/C++/README.md index 4ffbcb51..c1e467b8 100644 --- a/C++/README.md +++ b/C++/README.md @@ -9,10 +9,7 @@ | Program-07 | Program to print Pascal' triangle | | Program-08 | Program to reverse a string | | Program-09 | Program to check if two numbers are equal without using arithmetic operators or comparison operators. - | Program-10 | Program to Reverse words in a given string - | Program-10 | Program to find the missing number in a Sorted Array. | Program-15 | Program to find modular exponentiation. - -| Program-19| To check whether a number is in palindrome or not \ No newline at end of file +| Program-19| To check whether a number is in palindrome or not From 78daa671b461cf6c36836da65caafd2d93fe5b07 Mon Sep 17 00:00:00 2001 From: Dharmaksha <68665143+Dharmaksha@users.noreply.github.com> Date: Wed, 28 Oct 2020 00:40:57 +0530 Subject: [PATCH 3/5] Update README.md --- Python/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index 313454a0..b17427a9 100644 --- a/Python/README.md +++ b/Python/README.md @@ -28,8 +28,7 @@ | Program-24 | Program to convert binary number to decimal | | Program-25 | Program of a car game which shows if the car has started or stopped | | Program-26 | Program of a guessing game in which u guess the secret number with a guessing limit of 3 attempts. | -| Program-27 | Program which tells you the of downpayment of the house is 10% or 20% -depending if the owner has a good credit or not.The price of the house is to be entered in the output | +| Program-27 | Program which tells you the of downpayment of the house is 10% or 20% depending if the owner has a good credit or not.The price of the house is to be entered in the output | | Program-28 | Program to find out the GCD of any 2 given numbers | | Program-29 | Program which will display the fibonacci series | | Program-30 | Program to make simple calculator | From 69902da6d6d866df4720ad38e69559dbc4f7d996 Mon Sep 17 00:00:00 2001 From: Dharmaksha <68665143+Dharmaksha@users.noreply.github.com> Date: Wed, 28 Oct 2020 00:44:14 +0530 Subject: [PATCH 4/5] Create README.md --- Dart/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Dart/README.md diff --git a/Dart/README.md b/Dart/README.md new file mode 100644 index 00000000..a89a4896 --- /dev/null +++ b/Dart/README.md @@ -0,0 +1 @@ +# Dart From 2e85a94fcadb1c43a76fb58fc180a336e8ab05a9 Mon Sep 17 00:00:00 2001 From: Dharmaksha <68665143+Dharmaksha@users.noreply.github.com> Date: Wed, 28 Oct 2020 00:46:26 +0530 Subject: [PATCH 5/5] Create README.md --- kotlin/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 kotlin/README.md diff --git a/kotlin/README.md b/kotlin/README.md new file mode 100644 index 00000000..f9d85e6f --- /dev/null +++ b/kotlin/README.md @@ -0,0 +1 @@ +# Kotlin