-
Notifications
You must be signed in to change notification settings - Fork 2
se añaden los ejercicios realizados hasta el momento jgaona 14/07/2018 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jgaonap
wants to merge
1
commit into
master
Choose a base branch
from
jgbranch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/jorgeantonio/exercices/ex03_1_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex03_1_exercise; | ||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
| public class ShoppingCart { | ||
| public static void main (String[] args){ | ||
| System.out.println("Este es mi mensaje"); | ||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
src/main/java/jorgeantonio/exercices/ex04_1_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex04_1_exercise; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lo mismo aquí, checar paquetes |
||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
| public class ShoppingCart { | ||
| public static void main(String[] args) { | ||
| // Declare and initialize String variables. Do not initialize message yet. | ||
| String custName = "Jorge ", itemDesc = "loves the music"; | ||
| String message; | ||
|
|
||
|
|
||
| // Assign the message variable | ||
| message = custName + itemDesc; | ||
|
|
||
| // Print and run the code | ||
|
|
||
| System.out.println(message); | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
src/main/java/jorgeantonio/exercices/ex04_2_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex04_2_exercise; | ||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
| public class ShoppingCart { | ||
| public static void main(String[] args) { | ||
| String custName = "Jorge"; | ||
| String itemDesc = "Discs"; | ||
| String message = custName+" bought "+itemDesc; | ||
| double price = 52.0 , tax = 5.2; | ||
| int quantity = 2; | ||
| double total; | ||
| // Declare and initialize numeric fields: price, tax, quantity, and total. | ||
|
|
||
|
|
||
| // Modify message to include quantity | ||
| message = custName + " bought " + quantity + " " + itemDesc; | ||
|
|
||
| System.out.println(message); | ||
|
|
||
| total = price * quantity * tax; | ||
|
|
||
|
|
||
| // Calculate total and then print the total cost | ||
|
|
||
| System.out.println("and they cost " + total); | ||
|
|
||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/main/java/jorgeantonio/exercices/ex05_1_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex05_1_exercise; | ||
| public class ShoppingCart { | ||
|
|
||
| public static void main(String[] args) { | ||
| String custName = "Mary Smith"; | ||
| String itemDesc = "Shirt"; | ||
|
|
||
| // numeric fields | ||
| double price = 21.99; | ||
| int quantity = 2; | ||
| double tax = 1.04; | ||
| double total; | ||
| String message = custName+" wants to purchase "+quantity+" "+itemDesc; | ||
|
|
||
| // Calculating total cost | ||
| total = (price*quantity)*tax; | ||
|
|
||
|
|
||
| // Declare outOfStock variable and initialize it | ||
| boolean outOfStock = true; | ||
|
|
||
| // Test quantity and modify message if quantity > 1. | ||
| if(quantity > 1){ | ||
| message = message +"s"; | ||
| } | ||
|
|
||
| // Test outOfStock and notify user in either case. | ||
|
|
||
| if(outOfStock == true){ | ||
| System.out.println("The item unavailable"); | ||
| }else{ | ||
| System.out.println(message); | ||
| System.out.println("And the total is " + total); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/jorgeantonio/exercices/ex05_2_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex05_2_exercise; | ||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
|
|
||
| public class ShoppingCart { | ||
|
|
||
| public static void main(String[] args) { | ||
| // local variables | ||
| String custName = "Mary Smith"; | ||
| String message = custName + " wants to purchase a several items."; | ||
|
|
||
| //Declare and initialize the items String array | ||
| String items [] = new String[]{"Shirt","Jeans","Shoes",""}; | ||
|
|
||
|
|
||
|
|
||
| // Change message to show the number of items purchased. | ||
|
|
||
| message = "The items in total are " + items.length; | ||
|
|
||
| System.out.println(message); | ||
| // Print an element from the items array. | ||
| System.out.print(items[0]+"\n"); | ||
|
|
||
| } | ||
|
|
||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/jorgeantonio/exercices/ex05_3_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex05_3_exercise; | ||
|
|
||
| public class ShoppingCart { | ||
|
|
||
| public static void main(String[] args) { | ||
| // local variables | ||
| String custName = "Mary Smith"; | ||
| String message; | ||
| double price = 21.99; | ||
| int quantity = 2; | ||
| double tax = 1.04; | ||
|
|
||
| String items[]; | ||
| items = new String[4]; | ||
| items[0] = "Shirt"; | ||
| items[1] = "Belt"; | ||
| items[2] = "Scarf"; | ||
| items[3] = "Skirt"; | ||
|
|
||
| message = custName + " wants to purchase "+items.length+" items."; | ||
| System.out.println(message); | ||
|
|
||
| for (int i = 0; i < items.length; i++) { | ||
| System.out.println(items[i]); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } | ||
|
|
17 changes: 17 additions & 0 deletions
17
src/main/java/jorgeantonio/exercices/ex06_1_exercise/Item.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex06_1_exercise; | ||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
| public class Item { | ||
| public int id; | ||
| public String descr; | ||
| public int quantity; | ||
| public double price; | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/java/jorgeantonio/exercices/ex06_2_exercise/Item.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex06_2_exercise; | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * | ||
| * @author Hp | ||
| */ | ||
| public class Item { | ||
| public int itemId; | ||
| public String descr; | ||
| public int quantity; | ||
| public double price; | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/jorgeantonio/exercices/ex06_2_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex06_2_exercise; | ||
|
|
||
| public class ShoppingCart { | ||
|
|
||
| public static void main(String args[]) { | ||
| // Declare and initialize 2 Item objects | ||
| Item item1 = new Item(); | ||
| Item item2 = new Item(); | ||
|
|
||
| item1.itemId = 1; | ||
| item1.descr = "Playera de Brasil"; | ||
| item1.price = 500.00; | ||
| item1.quantity = 5; | ||
|
|
||
| item2.itemId = 1; | ||
| item2.descr = "Playera de Mexico"; | ||
| item2.price = 1150.00; | ||
| item2.quantity = 5; | ||
|
|
||
| // Print both item descriptions and run code. | ||
| System.out.println("The first description is " + item1.descr + "\n" | ||
| + "The second description is " + item2.descr); | ||
|
|
||
| item1 = item2; | ||
|
|
||
| System.out.println("The new description is " + item1.descr); | ||
|
|
||
| } | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/jorgeantonio/exercices/ex07_1_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * To change this license header, choose License Headers in Project Properties. | ||
| * To change this template file, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ | ||
| package ex07_1_exercise; | ||
|
|
||
| public class ShoppingCart { | ||
| public static void main (String[] args){ | ||
| String custName = "Steve Smith"; | ||
| String firstName; | ||
| int spaceIdx; | ||
|
|
||
| // Get the index of the space character (" ") in custName. | ||
| spaceIdx = custName.indexOf(" "); | ||
|
|
||
|
|
||
| // Use the substring method parse out the first name and print it. | ||
| firstName = custName.substring(0,spaceIdx); | ||
|
|
||
| System.out.println(firstName); | ||
|
|
||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/jorgeantonio/exercices/ex08_1_exercise/Item.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
|
|
||
| package ex08_1_exercise; | ||
|
|
||
| public class Item { | ||
| char color; | ||
|
|
||
| public boolean SetColor(char colorCode){ | ||
| if(colorCode == ' '){ | ||
| return false; | ||
| }else{ | ||
| this.color = colorCode; | ||
| return true; | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/jorgeantonio/exercices/ex08_1_exercise/ShoppingCart.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
| package ex08_1_exercise; | ||
|
|
||
| public class ShoppingCart { | ||
| public static void main(String[] args){ | ||
| Item item1 = new Item(); | ||
| if(true == item1.SetColor('e')){ | ||
| System.out.println("THE NEW COLOR IS " + item1.color); | ||
| }else{ | ||
| System.out.println("INVALID COLOR"); | ||
| } | ||
|
|
||
| // Call the setColor method on item1. Print the new color value from | ||
| // item1 if the method returns true. Otherwise print an "invalid color" | ||
| // message. | ||
|
|
||
|
|
||
| // Test the class, using both valid and invalid colors. | ||
|
|
||
|
|
||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/jorgeantonio/exercices/ex08_2_exercise/Item.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
|
|
||
| package ex08_2_exercise; | ||
|
|
||
|
|
||
| public class Item { | ||
| String desc; | ||
| int quantity; | ||
| double price; | ||
| char colorCode = 'U'; //'U' = Undetermined | ||
|
|
||
| public void displayItem() { | ||
| System.out.println("Item: " + desc + ", " + quantity + ", " | ||
| + price + ", "+colorCode); | ||
| } | ||
|
|
||
| // Write a public 3-arg setItemDisplay method that returns void. | ||
| public void setItemFields(String desc, int quantity, double price){ | ||
| this.desc = desc; | ||
| this.quantity = quantity; | ||
| this.price = price; | ||
| } | ||
| public int setItemFields(String desc, int quantity, double price,char colorCode){ | ||
| if(colorCode == ' '){ | ||
| return-1; | ||
| }else{ | ||
| this.colorCode = colorCode; | ||
| setItemFields(desc, quantity, price); | ||
| return 1; | ||
| } | ||
| } | ||
|
|
||
| // Write a public 4-arg setItemDisplay method that returns an int. | ||
|
|
||
|
|
||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Veo detalle en los paquetes. Por ejemplo en este archivo debería ser: jorgeantonio.exercises.ex03_1_exercise;