I have made a simple page, in which the content of the divs exceed their size within the second article .
This image reflects a 25% zoom of the original page which is 100%.
I want to initialize a constant variable, which is 'final', but I also want to include it in the constructor of a class but I don't know if this is ok:
public class Avion
{
private final BigDecimal limiteAltura;
public Avion(String limiteAltura)
{
this.limiteAltura = new BigDecimal(limiteAltura);
}
}
The constructor is supposed to initialize a field with qualifying values. It is initialized with a String
which by default will be null
but it gives me the impression that it can be done in another way. A constant has to be initialized at the time of its declaration or in the constructor. What I want to achieve is to be explicit not to ignore code.
How do I align a word horizontally with letters that are sequentially smaller?
Something like this:
I've tried to do this in HTML+CSS , but I can't.
This is my code:
.a{font-size: 1.3em;margin:auto;}
.b{font-size: 1em;margin:auto;}
.c{font-size: .9em;margin:auto;}
.d{font-size: .8em;margin:auto;}
.e{font-size: .7em;margin:auto;}
.f{font-size: .6em;margin:auto;}
.g{font-size:.5em ;margin:auto;}
.h{font-size: .4em;margin:auto;}
<h1>
<div class="a">M</div>
<div class="b">i</div>
<div class="c">L</div>
<div class="d">e</div>
<div class="e">t</div>
<div class="f">t</div>
<div class="g">r</div>
<div class="h">a</div>......texto normal
</h1>
I have tried to center what the page is but I always have space to occupy almost always as in the sketch above, what happens? And I don't get a few words aligned horizontally either.
index.html
<!DOCTYPE html>
<html lang="es">
<head>
<title>Miletra</title>
<meta charset="ISO-8859-1">
<meta name="keywords" content="HTML,CSS">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<ul class="contacto">
<li>T99</li>
<li><a href="mailto:[email protected]">email:[email protected]</a></li>
</ul>
<header id="banner">
<img src="img/x.jpg">
<div class="continente">
<h1><div class="a">M</div> <div class="b">i</div> <div class="c">C</div> <div class="d">o</div> <div class="e">c</div> <div class="f">i</div> <div class="g">n</div> <div class="h">a</div>...... 1º DAM</h1>
</div>
<nav class="menu">
<a href="#">Incio</a>
<a href="#">meu</a>
<a href="#">sericio a domicilio</a>
<a href="#">aceca de nosotros</a>
<a href="formulario.html">rero</a>
</nav>
</header>
<main class="group">
<section id="blog">
<div class="contenedor">
<article class="tamanio1">
<img src="img/x.jpg">
<h2>Roesa</h2>
</article>
<article class="tamanio2">
<h2>Hola queulo<h2>
<h3>Hola titulo<h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Quisque l libero ac molestie. In eu nisi
at elit maximus lobortis. </p>
</article>
</div>
<div class="contenedor">
<article class="tamanio1">
<img src="img/x.jpg">
<h2>Sushi</h2>
</article>
<article class="tamanio2">
<h2>Hola que titulo<h2>
<h3>Hola que l titulo<h3>
<p>Lorem ipsum dolor sibero ac molestie.</p>
</article>
</div>
</section>
<aside id="aside">
<article class="hola">
<h4>Recetas populares</h4>
<a href="#">Yaoune</a>
<a href="#">Okoomiyaki</a>
<a href="#">Mizutaki</a>
</article>
<article class="adios">
<a href="#">j</a>
<a href="#">Cona </a>
<a href="#">Pa/a>
</article>
</aside>
</main>
<div class="clear"></div>
<footer>
<p>© fghdfgh</p>
</footer>
</body>
</html>
main.css
@import url('../css/menu.css');
@import url('../css/banner.css');
{
margin: 0;
padding: 0;
font-size:16px;
}
.contacto{
position:fixed;
background:white;
height:40px;
z-index:100;
right:0;
width: 100%;
margin: auto;
}
.contacto ul{
clear: both;
width:70%;
}
.contacto li{
margin:10px 50px 10px 50px;
float:left;
position:relative;
left:25%;
list-style-type: none;
}
.contacto li a{
text-decoration:none;
}
body{
font-family: myFuente;
background-image: url("../img/x.jpg");
max-width:1024px;
margin-left:165px;
margin-right:100px;
}
header{
max-width:1024px;
position: fixed;
top: 0;
left: 0;
}
@font-face {
font-family: myFuente;
src: url(../fonts/Orbitron-Bold.ttf);
}
.continente {
width: 90%;
margin: auto;/*para alinear*/
}
.group {
position: relative;
background:white;
}
.group:before,
.group:after {
content: "";
display: table;
}
.group:after {
clear: both;
}
.group {
clear: both;
}
section {
float: left;
margin: 0 1%;
width: 70%;
}
aside {
float: right;
margin: 0 1%;
width: 25%;
}
header .continente {
display:table;
}
footer {
clear: both;
background:RGB(192,192,192);
width:100%;
color:white;
height:50px;
margin-top:-5px;
}
footer p {
padding-top:15px;
text-align:left;
margin-left:10px;
}
menu.css
.continente {
overflow: hidden;
}
#banner .menu {
width:100%;
position: absolute;
top:90%;
left:55%;
transform: translateX(-50%) translateY(-50%);
display:flex;
width:100%;
padding:10px;
}
#banner .menu a {
width:20%;
margin-top:1px;
margin-right:1px;
margin-bottom:1px;
margin-left:1px;
text-decoration:none;
color: white;
}
#banner .menu a:hover {
color:black;
}
banner.css
h1 {
display:flex;
letter-spacing: 0.3em;
}
#banner {
position: relative;
width: 100%;
right:200px;/*--aqui*/
margin-bottom:0;
}
#banner img {
width: 100%;
height: 100%;
}
#banner .continente{
position: absolute;
top:50%;
left:50%;
transform: translateX(-50%) translateY(-50%);
}
#banner h1 {
font-size: 1.750em;
color: white;
}
#banner {
/*overflow: hidden;*/
height: 300px;
}
#banner img {
height: auto;
}
Ok, and if I implement an interface once the contract is established, I do not overwrite it in that class where I have done it, public class nombre implements interface
but in its previously created subtype of the declared type, which is name , and its subtype would be, for example, subname .
inheritance summary
In general, we distinguish two main purposes of using inheritance: we can use it to inherit code (inherit code) and we can use it to inherit type (subtyping). The first is useful for code reuse, the second for polymorphism and specialization.
- When we inherit from concrete classes (“extends”) we do two things: we inherit the implementation and the type.
- When we inherit from interfaces (“implements”) we inherit a type but not the implementation.
- When we inherit from concrete classes ("extend") we do two things: we inherit the implementation and the type. When we inherit from interfaces ("implement") we inherit a type but not the implementation. For cases where both parts are useful we can inherit from abstract classes; here, we inherit the type and a partial implementation.
- When we inherit a complete implementation, we can choose to add or override methods . When no implementation of a type is inherited or a partial implementation of a type is inherited, the subclass must provide the implementation before it can be instantiated.
- Some other object-oriented languages also provide mechanisms for inheriting code without inheriting type. Java does not provide these types of constructs.
What is in bold I can't put the theory into practice, but I have tried the first two sentences.
David J. Barnes, Michael Kölling (2007). Object Oriented Programming with Java A Practical Introduction Using BlueJ (3rd ed.)
10.4 More abstract methods
….In Java, fields are handled differently than methods: fields cannot be overridden by subclass versions.
...
This rule applies regardless of whether a field is static or not.
So fields are just inherited and methods are overridden...is that correct?
I can't find the difference, although in all the searches they tell me the same thing but I can't fully break down its meaning to understand it. Data types referring to: ( https://msdn.microsoft.com/es-es/library/ms151817.aspx ) Oracle.
It tells me that the content of bank is well formed but not validated:
Error at line 26, column 8: element 'account' is not allowed for content model 'account,customer,depositor)*'
I know that the DTD is interpreted by me and could be wrong, but in the XML the info is fine.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bank [
<!ELEMENT bank (account,customer,depositor)*>
<!ELEMENT account (#PCDATA)>
<!ATTLIST account account-number ID #REQUIRED>
<!ATTLIST account branch-name (Downtown|Perryridge|Brighton) #REQUIRED>
<!ATTLIST account balance NMTOKEN #REQUIRED>
<!ELEMENT customer (#PCDATA)>
<!ATTLIST customer customer-name ID #REQUIRED>
<!ATTLIST customer customer-street CDATA #REQUIRED>
<!ATTLIST customer customer-city CDATA #REQUIRED>
<!ELEMENT depositor (#PCDATA)>
<!ATTLIST depositor account-number IDREF #REQUIRED>
<!ATTLIST depositor customer-name IDREF #REQUIRED>
] >
<bank>
<account account-number="A-101" branch-name="Downtown" balance="500"></account>
<account account-number="A-102" branch-name="Perryridge" balance="400"></account>
<account account-number="A-201" branch-name="Brighton" balance="900"></account>
<customer customer-name="Johnson" customer-street="Alma" customer-city="Palo Alto"></customer>
<customer customer-name="Hayes" customer-street="Main" customer-city="Harrison"></customer>
<depositor account-number="A-101" customer-name="Johnson"></depositor>
<depositor account-number="A-201" customer-name="Johnson"></depositor>
<depositor account-number="A-102" customer-name="Hayes"></depositor>
</bank>
If I want to traverse collections in a HashMap:
HashMap<Integer, Elemento>
) I would traverse it with aforeach()
also if I implement aIterator()
I don't understand very well the two ways to traverse it. I do not find the difference or their functions of each one to go through what I want to go through.
Element.java
package stackoverflowejemplo;
public class Elemento {
private int numeros;
private String nombre;
public Elemento(int numeros, String nombre){
this.numeros = numeros;
this.nombre = nombre;
}
public int getNumeros() {
return numeros;
}
public void setNumeros(int numeros) {
this.numeros = numeros;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String toString(){
return getNombre() +" - "+getNumeros() ;
}
}
Map.java
import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry;
public class Mapa {
public static void main(String[] args) {
HashMap<Integer, Elemento> map = new HashMap<>();
map.put(1,new Elemento(2,"hola"));
//foreach
} }
In an example with no overrides and nothing, just simple inheritance with the same method name, it should give an error but it doesn't or I'm wrong in my interpretation.
What I want is this but I want it to give me an error that the same method cannot be used.
Car.java:
public abstract class Coche
{
public abstract int sampleMethod(int y);
}
Limousine.java:
public class Limusina extends Coche
{
public Limusina()
{
}
public int sampleMethod(int y)
{
return y;
}
}
The expected result is 0.5f but in this algorithm what I get is 0.0f. What am I doing wrong?
public class AlgoritmoDeSequencia
{
private int n;
public AlgoritmoDeSequencia()
{
this.n = n;
}
public void algoritmo()
{
n = 2;
float primario = 1/n;
System.out.println(primario);
}
}
What is the difference in creating and defining these classes, for example:
HashMap<Object, Object> mapa = new HashMap<Object, Object>();
or this way:
Map<Object, Object> mapa = new HashMap<Object, Object>();
or this way:
Map<Object, Object> mapa = new HashMap<>();
Also:
HashSet<Object, Object> mapa = new HashSet<Object, Object>();
or this way:
Set<Object, Object> mapa = new HashSet<Object, Object>();
or this way:
Set<Object, Object> set = new HashSet<>();
Also:
ArrayList<Object> lista = new ArrayList<Object>();
or this way:
List<Object> lista = new ArrayList<Object>();
...and so on with collections... What is the best class definition? or because it is more preferable or more recommendable depending on what I want to use it for... or is there more correct ways?
I have searched the Internet but it has not been very clear to me what these reserved words mean and what functionalities they have in a class:
I try to do this problem with while and arrays but I can't get it to paint from 1 to 100 only with the even numbers.
ISSUE
public static void main(String[] args) {
int matriz1[][] = new int[5][5];
int i = 0;
int j = 0;
while (i < matriz1.length) {
matriz1[i][j]= i*matriz1.length;
System.out.print(matriz1[i][j]+" ");
while (j < matriz1[i].length) {
matriz1[i][j] = j+1;
System.out.print(matriz1[i][j]+" ");
}
j++;
}
i++;
System.out.println();
}
ATTEMPT TO RESULT TO THE PROBLEM
Hi to the whole community. I have written this POST in order to improve the understanding of class and instance variables . I have searched the Internet, and what has become clear to me is that:
I don't know if I have interpreted it correctly or if I need something more to know or understand and if I have interpreted correctly what I have written before.
It is an exercise that I cannot solve, besides that my knowledge about matrices is still zero and I don't know where to start.
public class ControlMatriz {
@SuppressWarnings({ "null" })
public void cien1NumNatural(int x, int supx)
{
for(int i=0;i<x;i++){
for(int j=0;j<supx;j++){
int[][] matrizM = null;
System.out.println(matrizM[i][j]);
if (matrizM[i][j] % 2==0)
System.out.println(matrizM[i][j]*5);
}
}
}
}
SET SESSION FOREIGN_KEY_CHECKS=0;
/* Drop Tables */
DROP TABLE IF EXISTS SE_COMPONE;
DROP TABLE IF EXISTS ARTICULO;
DROP TABLE IF EXISTS PEDIDO;
DROP TABLE IF EXISTS CLIENTE;
/* Create Tables */
CREATE TABLE ARTICULO
(
num_serie numeric NOT NULL,
id_articulo numeric,
nombre_articulo varchar(100),
PRIMARY KEY (num_serie),
UNIQUE (num_serie)
);
CREATE TABLE CLIENTE
(
dni varchar(12) NOT NULL,
nombre_cliente varchar(40),
apellidos varchar(50),
PRIMARY KEY (dni),
UNIQUE (dni)
);
CREATE TABLE PEDIDO
(
fecha datetime NOT NULL,
id_pedido numeric,
nombre_pedido varchar(100),
dni varchar(12) NOT NULL,
PRIMARY KEY (fecha),
UNIQUE (fecha),
UNIQUE (dni)
);
CREATE TABLE SE_COMPONE
(
fecha datetime NOT NULL,
num_serie numeric NOT NULL,
cantidad numeric,
peso double,
caducidad datetime,
UNIQUE (fecha),
UNIQUE (num_serie)
);
/* Create Foreign Keys */
ALTER TABLE SE_COMPONE
ADD FOREIGN KEY (num_serie)
REFERENCES ARTICULO (num_serie)
ON UPDATE RESTRICT
ON DELETE RESTRICT
;
ALTER TABLE PEDIDO
ADD FOREIGN KEY (dni)
REFERENCES CLIENTE (dni)
ON UPDATE RESTRICT
ON DELETE RESTRICT
;
ALTER TABLE SE_COMPONE
ADD FOREIGN KEY (fecha)
REFERENCES PEDIDO (fecha)
ON UPDATE RESTRICT
ON DELETE RESTRICT
;
Mens. 195, Level 15, State 7, Line 2 'SESSION' is not a recognized SET option. Mens. 102, Level 15, State 1, Line 53 Incorrect syntax around ','. Mens. 156, Level 15, State 1, Line 66 Incorrect syntax near keyword 'RESTRICT'. Mens. 156, Level 15, State 1, Line 74 Incorrect syntax near keyword 'RESTRICT'. Mens. 156, Level 15, State 1, Line 82 Incorrect syntax near keyword 'RESTRICT'.
What I want to achieve is to activate a shield with colliders or triggers, with the left mouse button "Fire 2" when a rocket hits me and does not destroy me.