329 lines
10 KiB
TeX
329 lines
10 KiB
TeX
\documentclass[a4paper, 12pt]{article}
|
|
\usepackage[bookmarks=true, unicode]{hyperref}
|
|
\usepackage{bookmark}
|
|
|
|
\usepackage{fontawesome}
|
|
|
|
\usepackage[spanish]{babel}
|
|
\usepackage[utf8]{inputenc}
|
|
|
|
\usepackage{graphicx}
|
|
|
|
\usepackage{listings}
|
|
\usepackage{xcolor}
|
|
|
|
\renewcommand{\lstlistingname}{Código}
|
|
\definecolor{codegreen}{rgb}{0,0.6,0}
|
|
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
|
|
\definecolor{codepurple}{rgb}{0.58,0,0.82}
|
|
\definecolor{backcolour}{rgb}{0.98,0.98,0.98}
|
|
|
|
\lstdefinestyle{mystyle}{
|
|
backgroundcolor=\color{backcolour},
|
|
commentstyle=\color{codegreen},
|
|
keywordstyle=\color{magenta},
|
|
numberstyle=\tiny\color{codegray},
|
|
stringstyle=\color{codepurple},
|
|
basicstyle=\ttfamily\footnotesize,
|
|
breakatwhitespace=false,
|
|
breaklines=true,
|
|
captionpos=b,
|
|
keepspaces=true,
|
|
numbers=left,
|
|
numbersep=5pt,
|
|
showspaces=false,
|
|
showstringspaces=false,
|
|
showtabs=false,
|
|
tabsize=2,
|
|
basicstyle=\ttfamily,
|
|
moredelim=[il][\textcolor{pgrey}]{$$},
|
|
moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%}
|
|
}
|
|
|
|
\lstset{style=mystyle}
|
|
\setlength{\parindent}{0pt}
|
|
|
|
|
|
\title{Cafeteria}
|
|
\author{Tuzikuz}
|
|
\date{\today}
|
|
|
|
\raggedright
|
|
|
|
|
|
% enumitem clashes with enumerate
|
|
\usepackage{enumitem,amssymb}
|
|
\newlist{todolist}{itemize}{2}
|
|
\setlist[todolist]{label=$\square$}
|
|
|
|
\usepackage{pifont}
|
|
\newcommand{\cmark}{\ding{51}}%
|
|
\newcommand{\xmark}{\ding{55}}%
|
|
\newcommand{\done}{\rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}}%
|
|
\hspace{-2.5pt}}
|
|
\newcommand{\wontfix}{\rlap{$\square$}{\large\hspace{1pt}\xmark}}
|
|
|
|
|
|
% \begin{lstlisting}[language=Java, caption=Enum java] \end{lstlisting}
|
|
% \vspace{0.5cm}
|
|
|
|
\begin{document}
|
|
\maketitle
|
|
|
|
|
|
\newpage
|
|
|
|
|
|
\tableofcontents
|
|
|
|
\section{TODO}
|
|
|
|
\begin{todolist}
|
|
\item[\done] Inicio
|
|
|
|
\item[\done] Ver menu
|
|
\begin{todolist}
|
|
\item[\done] Ver detalles
|
|
\end{todolist}
|
|
|
|
\item[\done] Pedidos
|
|
\begin{todolist}
|
|
\item[\done] Refund
|
|
\item[\done] Mis productos
|
|
\item[\done] Recargar saldo
|
|
\item[\done] Reducir saldo
|
|
\item[\done] Eliminar pedido
|
|
\item[\done] Factura
|
|
\end{todolist}
|
|
|
|
\item[\done] Debug
|
|
\end{todolist}
|
|
|
|
\section{Index}
|
|
|
|
\subsection{Paginas}
|
|
\url{https://www.youtube.com}
|
|
|
|
\url{https://www.digitalocean.com}
|
|
|
|
\url{https://stackoverflow.com}
|
|
|
|
\url{https://www.w3schools.com}
|
|
|
|
\url{https://www.javatpoint.com}
|
|
|
|
\url{https://forums.oracle.com}
|
|
|
|
\url{https://www.cs.utexas.edu}
|
|
|
|
\url{www.edureka.co}
|
|
|
|
|
|
|
|
|
|
\section{Printf in java}
|
|
|
|
\begin{lstlisting}[
|
|
language=Java,
|
|
caption=Printf java,
|
|
extendedchars=true,
|
|
inputencoding=utf8,
|
|
literate={á}{{\'a}}1 {ã}{{\~a}}1 {é}{{\'e}}1,
|
|
]
|
|
/*
|
|
Format Specifiers
|
|
Lets look at the available format specifiers available for printf:
|
|
|
|
%c character
|
|
%d decimal (integer) number (base 10)
|
|
%e exponential floating-point number
|
|
%f floating-point number
|
|
%i integer (base 10)
|
|
%o octal number (base 8)
|
|
%s String
|
|
%u unsigned decimal (integer) number
|
|
%x number in hexadecimal (base 16)
|
|
%t formats date/time
|
|
%% print a percent sign
|
|
\% print a percent sign
|
|
|
|
|
|
Escape Characters
|
|
Following are the escape characters available in printf():
|
|
|
|
\b backspace
|
|
\f next line first character starts to the right of current line last character
|
|
\n newline
|
|
\r carriage return
|
|
\t tab
|
|
\\ backslash
|
|
*/
|
|
|
|
int var = 10;
|
|
System.out.printf("%i", var);\end{lstlisting}
|
|
|
|
\vspace{0.5cm}
|
|
|
|
\href{https://www.digitalocean.com/community/tutorials/java-printf-method}{Java printf() - Print Formatted String to Console | DigitalOcean}
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting}[language=Java, caption=String format]
|
|
int a = 1, b = 2, c = 3;
|
|
|
|
return String.format("%d %d %d", a, b, c);\end{lstlisting}\vspace{0.5cm}
|
|
|
|
\href{https://www.geeksforgeeks.org/java-string-format-method-with-examples/}{Java String format() Method With Examples - GeeksforGeeks}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://stackoverflow.com/questions/23461344/can-a-return-statement-be-formatted-like-a-printf}{java - Can a return statement be formatted like a printf? - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.digitalocean.com/community/tutorials/java-printf-method}{Java printf() - Print Formatted String to Console | DigitalOcean}
|
|
|
|
|
|
|
|
|
|
\section{Enum}
|
|
|
|
\begin{lstlisting}[language=Java, caption=Enum java]
|
|
enum Level {
|
|
LOW,
|
|
MEDIUM,
|
|
HIGH
|
|
}
|
|
|
|
Level myVar = Level.MEDIUM;\end{lstlisting}\vspace{0.5cm}
|
|
|
|
\href{https://www.w3schools.com/java/java_enums.asp}{w3schools Java Enums}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://stackoverflow.com/questions/23058275/should-i-use-uppercase-or-camelcase-in-label-enums}{stackoverflow java - Should I use uppercase or camelcase in label enums? - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://stackoverflow.com/questions/8143995/should-java-member-enum-types-be-capitalized}{stackoverflow eclipse - Should Java member enum types be capitalized? - Stack Overflow}
|
|
|
|
|
|
|
|
|
|
\section{Set and get}
|
|
\begin{lstlisting}[language=Java, caption=Set get]
|
|
public class Person {
|
|
private String name; // private = restricted access
|
|
|
|
// Getter
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
// Setter
|
|
public void setName(String newName) {
|
|
this.name = newName;
|
|
}
|
|
}
|
|
\end{lstlisting}
|
|
\href{https://www.w3schools.com/java/java_encapsulation.asp}{Java Encapsulation and Getters and Setters}
|
|
|
|
|
|
|
|
|
|
\section{Extends and List}
|
|
\begin{lstlisting}[language=Java, caption=Extends List]
|
|
// You could use java generic.First create a java collection (ex: List) with supper class type, Product. Now you could add any sub classes (Monitor , Keyboard etc) in your collection (List) that extends of class Product.
|
|
|
|
|
|
public class Product{}
|
|
public class Monitor extends Product{}
|
|
|
|
public class Keyboard extends Product{}
|
|
|
|
List<Product> products = new ArrayList<Product>();
|
|
products.add(new Monitor());
|
|
products.add(new Keyboard());\end{lstlisting}\vspace{0.5cm}
|
|
|
|
\href{https://stackoverflow.com/questions/18288655/storing-multiple-object-types-in-a-list}{java - Storing multiple object types in a List - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://es.stackoverflow.com/questions/496024/c%C3%B3digo-en-java-con-arraylist-y-herencia}{Código en Java con arrayList y herencia - Stack Overflow en español]}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.javatpoint.com/arraylist-implementation-in-java}{ArrayList Implementation in Java - Javatpoint}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://forums.oracle.com/ords/apexds/post/to-extend-arraylist-or-to-not-extend-arraylist-1665}{To extend ArrayList, or to not extend ArrayList - Oracle Forums}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.w3resource.com/java-exercises/oop/java-oop-exercise-18.php}{Java - Restaurant menu, average rating}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.w3schools.com/java/java_inheritance.asp}{Java Inheritance (Subclass and Superclass)}
|
|
\vspace{0.5cm}
|
|
|
|
\begin{enumerate}
|
|
\item Class array: \href{https://youtu.be/QTPIYcQ6Cxc?t=1100}{ArrayList inheritance Everything - YouTube}
|
|
\item super(): \href{https://youtu.be/QTPIYcQ6Cxc?t=2426}{ArrayList inheritance Everything - YouTube}
|
|
\item Return string: \href{https://youtu.be/QTPIYcQ6Cxc?t=2629}{ArrayList inheritance Everything - YouTube}
|
|
\end{enumerate}
|
|
|
|
|
|
\section{Package}
|
|
|
|
\begin{lstlisting}[language=Java, caption=Enum java]
|
|
import mytest.Mypckg;
|
|
|
|
public class Learn {
|
|
public static void main(String[] args) {
|
|
System.out.println("Hello World");
|
|
Mypckg.show();
|
|
}
|
|
}
|
|
package mytest;
|
|
public class Mypckg {
|
|
public static void show(){
|
|
System.out.println("Good Moring");
|
|
}
|
|
}
|
|
\end{lstlisting}\vspace{0.5cm}
|
|
|
|
\href{https://stackoverflow.com/questions/63868318/how-to-import-class-of-one-file-to-another-in-a-subfolder-in-java-using-vscode}{How to import class of one file to another in a subfolder in Java using vscode - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://stackoverflow.com/questions/26432953/java-import-sub-sub-directory}{Java import sub-sub directory - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.youtube.com/watch?v=PsuZ0WxDJ0M}{How To Import A Class In Java From Another Package or Project - Java Tutorial - YouTube}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.youtube.com/watch?v=3ybNZM6cP3M}{Calling Java class from other file in Visual Studio Code - YouTube}
|
|
|
|
\vspace{0.5cm}
|
|
|
|
|
|
\section{User input}
|
|
\begin{lstlisting}[language=Java, caption=Normal input]
|
|
InputStreamReader inputStreamReader new InputStreamReader (System.in);
|
|
|
|
BufferedReader buffer = new BufferedReader (inputStreamReader);
|
|
|
|
String userInput = buffer.readLine();
|
|
|
|
int userInputToInt = Integer.parseInt(userInput);
|
|
\end{lstlisting}\vspace{1cm}
|
|
|
|
\begin{lstlisting}[language=Java, caption=Others input]
|
|
BufferedReader buffer = new BufferedReader (new InputStreamReader (System.in));
|
|
|
|
int userInput = Integer.parseInt(buffer.readLine());\end{lstlisting}\vspace{0.5cm}
|
|
|
|
\href{https://www.cs.utexas.edu/~mitra/csSpring2004/cs313/assgn/BufferedReader.html#:~:text=BufferedReader%20input%20%3D%20new%20BufferedReader%20(new,readLine()%3B}{Using Buffered Readers}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://stackoverflow.com/questions/25491997/how-to-read-multiple-integer-values-from-one-line-in-java-using-bufferedreader-o}{arrays - How to read multiple integer values from one line in Java using BufferedReader object? - Stack Overflow}
|
|
|
|
\vspace{0.3cm}
|
|
\href{https://www.edureka.co/community/40038/how-to-take-input-using-bufferedreader-in-java}{How to take input using BufferedReader in Java | Edureka Community}
|
|
|
|
|
|
\end{document}
|