Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

dario lobos

Greenhorn
+ Follow
since Jul 04, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dario lobos

If you use a hashcode with time and you are requesting a data with 4 parameters
data.1
data.2
data.3
data.4
When you request you do data.hascode() and store it.
When you receive the data as receiveddata
if !(storeddatahascode = receiveddata.hashcode())
YOU HAVE TO REQUEST THE DATA AGAIN maybe with other parameters.
When you store data in the table YOU CAN OVERRIDE THE HASCODE and use a hashcode without time if you need it.
4 days ago
To compare parts of a particular object and not all the object. Hash you can use it for encription. Is depends on what you use it for. if you dont like to use time in hashcode feel free to dont use it
4 days ago
To give an example of usage. you can have a module of injection with a database that have

Air flow input
throttle position input
lamnda sensor value input
barometer input
gas to injector(time for solenoid) output

The output is no more usefull after a second and you have to discard this output with the hashcode with time you can do it fast.
4 days ago
I the hascode that i did and the equals i acomplish that if a.equals(b)  a.hascode() = b.hascode() doing the requests of hascode at the same time.
4 days ago
The definition of the rule dont speak nothing about time if you do with my hashcode

a.hascode().equals(b.hascode())
With the proper equal will work

Also if a.equals(b) with my hascode
during a second a.hashcode() = b.hashcode()


AND ANY TIME THAT YOU NEED YOU CAN OVERRIDE THE HASHCODE.

IF YOU GONNA STORE a.hascode() and later you gonna request a searching as a.hascode() this will not usefull. The request of hashcode have to be at the same time and  for comparations.

This dont brake the law i only apply the law with a restiction in a period of time to see if it work and during which period of time.
4 days ago
Also i tried with random seed and second to do a hashcode with fast expire date and with no calculation at all.
4 days ago
yes i did a hashcode with time. This depends on what it used for. I tried with millisecond and dont work the next seach do one millisecond more. Was a practice with java timing. The java is not so fast. Cant be implemented a database to control a secure fast device the answer is over 1 millisecond. So can warranty only 100 hz. An engine module needs at least 100 hz (6000 rpm / 60 seconds) so is to slow fot that. the next learning will be exceptions if i found something i interesting i can share it with you.
4 days ago

package pruebajava;
//@FunctionalInterface
public interface Fechalong {
long LongDateTime();
public static long fechal =0;
}
package pruebajava;
@FunctionalInterface
interface Fechasegundos {
long LongFechaSegundos();
public static long fechas =0;
}
4 days ago
package pruebajava;
import java.util.*;
import pruebajava.Bicicleteria;
public class Navbicicleteria extends Bicicleteria  implements Comparator<Bicicleteria>{
@Override
public int compare(Bicicleteria o1 , Bicicleteria o2)
{
if ((!((o1 instanceof Bicicleteria)
&&  (o2 instanceof Bicicleteria)))|| (o1 == null) || (o2 == null)) {return -1;};
if (o1 == o2){return 0;};
Bicicleteria bici1 = (Bicicleteria) o1;
Bicicleteria bici2 = (Bicicleteria) o2;
return (bici1.Getpmarca().compareToIgnoreCase(bici2.Getpmarca()) + bici1.Getpmodelo().compareToIgnoreCase(bici2.Getpmodelo()) + bici1.Getpcolor().compareToIgnoreCase (bici2.Getpcolor()));
};
@Override
public  boolean equals(Object o){
 if (!(o instanceof Bicicleteria) || o== null ) {return false ;};
 if (this == o){
   return true;
};  
 Bicicleteria bici = (Bicicleteria) o;
return
(this.pmarca.compareToIgnoreCase(bici.pmarca) == 0 && this.pmodelo.compareToIgnoreCase(bici.pmodelo) == 0 && this.pcolor.compareToIgnoreCase(bici.pcolor) == 0 );
};
public Boolean Getbici(Bicicleteria a,Bicicleteria b){
return a.equals(b);
};
@Override
public int hashCode(){
int d = 3;
GregorianCalendar fecha = new GregorianCalendar();
int c = fecha.get(Calendar.SECOND);
int a = d*( Getpmarca().compareTo(Getpmodelo()) + Getpmodelo().compareTo(Getpcolor()))+ c;
return a ;
};
Object o = null ;
@Override
public String toString(){
return
"Fecha/hora: " + pfecha + " control nro.: "+ pfechasegundos + " Marca: " + pmarca + " Modelo: " + pmodelo + " Color: " + pcolor + " Cantidad: " + pcantidad + " Disponible: " + pdisponible + " precio: " + String.format("%.2f%n",pprecio)  ;
};
//public static void main(String[] args) {
static NavigableSet<Bicicleteria> navigablebiciset= new TreeSet<>(new Navbicicleteria());
static void bicirepetida(){
 System.out.println("La bicicileta que intenta ingresar ya existe");
};
static void biciingresada(){
 System.out.println("La bicicleta ha sido ingresada");
}
static public void Nuevabici( String pmarca,String pmodelo,String pcolor){
Bicicleteria newbici = new Bicicleteria(pmarca,pmodelo,pcolor);
if (navigablebiciset.ceiling(newbici)==null){navigablebiciset.add(newbici);
biciingresada();}
else {bicirepetida();};
};
static public void precioCambiado(){System.out.println("Precio modificado");};
static public void biciInexiste(){System.out.println("Tipo de bicicleta inexistente");};
static public void CambioPrecio( String pmarca, String pmodelo,String pcolor, double newprecio ){
Bicicleteria getbici= new Bicicleteria (pmarca ,pmodelo , pcolor );
if ((!(navigablebiciset.ceiling(getbici)==null)) &&
(navigablebiciset.ceiling(getbici).equals(getbici)==true)){ navigablebiciset.ceiling(getbici).pprecio = newprecio;
precioCambiado();}
else {biciInexiste();};
getbici = null;
};
static public void cantCambiada(){
 System.out.println("Cantidad de bicicletas cambiada");
};
static public void Cambiocantidad( String pmarca, String pmodelo, String pcolor, int newcantidad){
Bicicleteria getbici = new Bicicleteria(pmarca,pmodelo,pcolor);
if((!(navigablebiciset.ceiling(getbici)==null)&& (navigablebiciset.ceiling(getbici).equals(getbici)==true))){navigablebiciset.ceiling(getbici).pcantidad = newcantidad;
if (navigablebiciset.ceiling(getbici).pcantidad > 0){navigablebiciset.ceiling(getbici).pdisponible = true;}
else
{navigablebiciset.ceiling(getbici).pdisponible = false;};
cantCambiada();}
else{ biciInexiste();};
getbici = null;
};
public static void main(String[] args){
navigablebiciset.add(new Bicicleteria("a", "b", "c"));
navigablebiciset.add(new Bicicleteria("d", "e", "f"));
navigablebiciset.add(new Bicicleteria("a", "b", "c"));
System.out.println(navigablebiciset);
CambioPrecio("d","e","f",20000);
System.out.println("nuevoprecio: ");
System.out.println(navigablebiciset);
Cambiocantidad("a","b","c",25);
System.out.println("nuevacantidad: ");
System.out.println(navigablebiciset);
System.out.println("nueva Bicicleta;");
Nuevabici("g","h","j");
System.out.println(navigablebiciset);
Nuevabici("a","b","c");
System.out.println(navigablebiciset);
}
}
4 days ago
package pruebajava;
import java.util.*;
import java.util.GregorianCalendar;
import pruebajava.Fechalong;
import pruebajava.Fechasegundos;
public class Bicicleteria
{
  String pmarca;
  String pmodelo;
  String pcolor;
  double pprecio;
  boolean pdisponible;
  int pcantidad;
  int pcontador;
  static int spcontador;
  long pfecha;
  long pfechasegundos ;
public Bicicleteria(){};

public static Calendar haceCalendario(){
 Calendar date = new GregorianCalendar();
 return date;
};
public Bicicleteria(String pmarca, String pmodelo, String pcolor)
{
  this.pmarca = pmarca;
  this.pmodelo  = pmodelo;
  this.pcolor = pcolor;
  this.pprecio = 0;
  this.pcantidad = 0;
  this.pdisponible = false;
 spcontador++;
  this.pcontador = spcontador;
//static Fechasegundos fechas = ()->{
Fechasegundos fechs = new Fechasegundos()
{
public long LongFechaSegundos()
{
  long pdia2;
  long pmes2;
  long pdiasmes;
  long pyear2;
  long pyviciesto;
  long phora2;
  long pminuto2;
  long psegundo2;
  long pcontfechasegundos;
  long pmilis;
Calendar date = haceCalendario();
pdia2 = (long) date.get(Calendar.DAY_OF_MONTH);
pmes2 = (long) date.get(Calendar.MONTH);
switch ( (int) pmes2){
case 1:  pdiasmes = 31;
break;
case 2:  pdiasmes = 28;
break;
case 3:  pdiasmes = 31;
break;
case 4:  pdiasmes = 30;
break;
case 5:  pdiasmes = 31;
break;
case 6:  pdiasmes = 30;
break;
case 7:  pdiasmes = 31;
break;
case 8:  pdiasmes = 31;
break;
case 9:  pdiasmes = 30;
break;
case 10: pdiasmes = 31;
break;
case 11: pdiasmes = 30;
break;
default: pdiasmes = 31;};
pyear2 = (long) date.get(Calendar.YEAR);
if
(((pyear2-2016) % 4) == 0)
pyviciesto = ((pyear2/4)-1)*24* 3600;
else
pyviciesto = (pyear2/4)*24*3600;
phora2 = (long) date.get(Calendar.HOUR);
pminuto2 = (long) date.get(Calendar.MINUTE);
psegundo2 = (long) date.get(Calendar.SECOND);
pmilis = (long) date.get(Calendar.MILLISECOND);
pcontfechasegundos = (psegundo2 + pminuto2* 60 + phora2 * 3600 + pdia2 * 24 * 3600 + pdiasmes * 24 * 3600 + pyear2 * 365 * 24 * 3600 + pyviciesto)*1000 + pmilis;
return  (long) pcontfechasegundos;
};
};
//static Fechalong fech = ()->{
Fechalong fech = new Fechalong()
{
public long LongDateTime()
{
  long pdia;
  long pmes;
  long pyear;
  long phora;
  long pminuto;
  long psegundo;
  long pcontfechahora;
Calendar date = haceCalendario();
pdia = (long) date.get(Calendar.DAY_OF_MONTH);
pmes = (long) date.get(Calendar.MONTH);
pyear = (long) date.get(Calendar.YEAR);
phora = (long) date.get(Calendar.HOUR);
pminuto = (long) date.get(Calendar.MINUTE);
psegundo = (long) date.get(Calendar.SECOND);
pcontfechahora = psegundo +  pminuto * 100 + phora * 10000 + pdia * 1000000+ pmes * 100000000 + pyear * 10000 * 1000000;
return (long) pcontfechahora;
};
};
this.pfecha = fech.LongDateTime();
this.pfechasegundos = fechs.LongFechaSegundos();
};
public String Getpmarca(){
  return  this.pmarca;
};
public String Getpmodelo(){
  return  this.pmodelo;
};
public String Getpcolor(){
  return  this.pcolor;
};
public Double Getpprecio(){
  return this.pprecio;
};
public int Getpcantidad(){
  return  this.pcantidad;
};
public boolean Getpdisponible(){
  return  this.pdisponible;
};
public void Setpprecio(double pprecio){
  this.pprecio = pprecio;
};
public void Setpdisponible(boolean pdisponible){
 this.pdisponible = pdisponible;
};
public void Setpcantidad(int pcantidad){
 this.pcantidad = pcantidad;
};
@Override
public  boolean equals(Object o){
 if (!(o instanceof Bicicleteria) || o== null ) {return false ;};
 if (this == o){
   return true;
};
Bicicleteria bici = (Bicicleteria) o;
return
(this.pmarca.compareToIgnoreCase(bici.pmarca) == 0 && this.pmodelo.compareToIgnoreCase(bici.pmodelo) == 0 && this.pcolor.compareToIgnoreCase(bici.pcolor) == 0 );
};
public Boolean Getbici(Bicicleteria a,Bicicleteria b){
return a.equals(b);
};
@Override
public int hashCode(){
int d = 3;
GregorianCalendar fecha = new GregorianCalendar();
int c = fecha.get(Calendar.SECOND);
int a = d*( Getpmarca().compareTo(Getpmodelo()) + Getpmodelo().compareTo(Getpcolor()))+ c;
return a ;
};
Object o = null ;
@Override
public String toString(){
return
"Fecha: " + pfecha + " control nro.: " + pfechasegundos + " Marca: " + pmarca + " Modelo: " + pmodelo + " Color: " + pcolor +" Cantidad: " + pcantidad + " Disponible: " + pdisponible + " precio: " + String.format("%.2f%n",pprecio);
};
public static void main(String[] args) {
Bicicleteria bicicleta1 = new Bicicleteria("a", "a", "a");
Bicicleteria bicicleta2 = new Bicicleteria("a","a","a");
Bicicleteria bicicleta3 = new Bicicleteria("a","f","g");
// System.out.println  (fech.LongDateTime());
System.out.println(bicicleta1.pmarca); System.out.println(bicicleta1.pmodelo);
System.out.println(bicicleta1.pcolor);
System.out.println(bicicleta1.pcantidad); System.out.println(bicicleta1.pdisponible);  
System.out.println(bicicleta1.pcontador);
System.out.println(bicicleta2.pmarca);
System.out.println(bicicleta2.pcontador);
System.out.println(bicicleta1.equals (bicicleta2));
System.out.println(bicicleta2.equals(bicicleta3));
System.out.println(bicicleta1);
System.out.println("hashCode1: " + bicicleta1.hashCode());
System.out.println(bicicleta2);
System.out.println("hashCode2: " + bicicleta2.hashCode());
System.out.println(bicicleta3);
System.out.println("hashCode3: " + bicicleta3.hashCode());;
GregorianCalendar df = new  GregorianCalendar();
System.out.println  (haceCalendario());
System.out.println( df.get(Calendar.SECOND));
}
}
4 days ago
is safe microsoft Onedrive. Have the java files. I cant attach the files and the window now dont let me paste the code. in my phone dont have the code option.
4 days ago
Now work all. The absolute millisecond long that i did i corrected yesterday is only to make an excersice. I only have an old phone to program. In the phones dont appear the options that you are talking about. Now I gonna learn exceptions. I try to make methods to add and modify to live the excemptions only for data. I dont learn data transfers already. I speak spanish. To share with the forum i only can copy and paste. I am overriding methods more than it needed this is to be shure that this method is that is being used and to have it in the class to see wich method that i am using. The p is to say that this storage a PRIMITIVE VALUE.
4 days ago

dario lobos wrote:

Carey Brown wrote:
Sorry in my phone dont appear the code option. I erased the empty lines. is difficult to send the message. The server have problems.

In this part i have problems the rest is working. I am trying to put the date and time  in a long field using the constructor. Also i did a long field with this time and date but all converted in seconds and the last three digists are milliseconds. I did it with an interface but i cant include it in the constructor.I tried in other class, in the same class and inside of the constructor.

package pruebajava;
import java.util.*;
import pruebajava.Fechalong;
import pruebajava.Fechasegundos;
import pruebajava.intdatetime;
public class Bicicleteria
{
  String pmarca;
  String pmodelo;
  String pcolor;
  double pprecio;
  boolean pdisponible;
  int pcantidad;
  int pcontador;
  static int spcontador;
  long pfecha;
  long pfechasegundos ;
public Bicicleteria(){};
public Bicicleteria(String pmarca, String pmodelo, String pcolor)
{
  this.pmarca = pmarca;
  this.pmodelo  = pmodelo;
  this.pcolor = pcolor;
  this.pprecio = 0;
  this.pcantidad = 0;
  this.pdisponible = false;
 spcontador++;
  this.pcontador = spcontador;
//  this.pfecha = fech.Longdatetime();
// this.pfechasegundos = fechs.LongFechaSegundos();
//static Fechasegundos fechas = ()->{
Fechasegundos fechs = new Fechasegundos()
{
public long LongFechaSegundos()
{
  long pdia2;
  long pmes2;
  long pdiasmes;
  long pyear2;
  long pyviciesto;
  long phora2;
  long pminuto2;
  long psegundo2;
  long pcontfechasegundos;
  long pmilis;
GregorianCalendar date = new GregorianCalendar();
pdia2 = (long) date.get(Calendar.DAY_OF_MONTH);
pmes2 = (long) date.get(Calendar.MONTH);
switch ( (int) pmes2){
case 1:  pdiasmes = 31;
break;
case 2:  pdiasmes = 28;
break;
case 3:  pdiasmes = 31;
break;
case 4:  pdiasmes = 30;
break;
case 5:  pdiasmes = 31;
break;
case 6:  pdiasmes = 30;
break;
case 7:  pdiasmes = 31;
break;
case 8:  pdiasmes = 31;
break;
case 9:  pdiasmes = 30;
break;
case 10: pdiasmes = 31;
break;
case 11: pdiasmes = 30;
break;
default: pdiasmes = 31;};
pyear2 = (long) date.get(Calendar.YEAR);
if
((pmes2 > 1) && (((pyear2-2016) % 4) == 0))
pyviciesto = 24 * 3600;
else
pyviciesto = 0;
phora2 = (long) date.get(Calendar.HOUR);
pminuto2 = (long) date.get(Calendar.MINUTE);
psegundo2 = (long) date.get(Calendar.SECOND);
pmilis = (long) date.get(Calendar.MILLISECOND);
pcontfechasegundos = (psegundo2 + pminuto2* 60 + phora2 * 3600 + pdia2 * 24 * 3600 + pdiasmes * 24 * 3600 + pyear2 * 365 * 24 * 3600 + pyviciesto)*1000 + pmilis;
return  (long) pcontfechasegundos;
};
};
//static Fechalong fech = ()->{
Fechalong fech = new Fechalong()
{
public long LongDateTime()
{
  long pdia;
  long pmes;
  long pyear;
  long phora;
  long pminuto;
  long psegundo;
  long pcontfechahora;
GregorianCalendar date2 = new GregorianCalendar();
pdia = (long) date2.get(Calendar.DAY_OF_MONTH);
pmes = (long) date2.get(Calendar.MONTH);
pyear = (long) date2.get(Calendar.YEAR);
phora = (long) date2.get(Calendar.HOUR);
pminuto = (long) date2.get(Calendar.MINUTE);
psegundo = (long) date2.get(Calendar.SECOND);
pcontfechahora = psegundo +  pminuto * 100 + phora * 10000 + pdia * 1000000+ pmes * 100000000 + pyear * 10000 * 1000000;
return (long) pcontfechahora;
//this.pfecha =     fech.Longdatetime();
//this.pfechasegundos = fechs.LongFechaSegundos();
};
};
};
public String Getpmarca(){
  return  this.pmarca;
};
public String Getpmodelo(){
  return  this.pmodelo;
};
public String Getpcolor(){
  return  this.pcolor;
};
public Double Getpprecio(){
  return this.pprecio;
};
public int Getpcantidad(){
  return  this.pcantidad;
};
public boolean Getpdisponible(){
  return  this.pdisponible;
};
public void Setpprecio(double pprecio){
  this.pprecio = pprecio;
};
public void Setpdisponible(boolean pdisponible){
 this.pdisponible = pdisponible;
};
public void Setpcantidad(int pcantidad){
 this.pcantidad = pcantidad;
};
@Override
public  boolean equals(Object o){
 if (!(o instanceof Bicicleteria) || o== null ) {return false ;};
 if (this == o){
   return true;
};
Bicicleteria bici = (Bicicleteria) o;
return
(this.pmarca.compareToIgnoreCase(bici.pmarca) == 0 && this.pmodelo.compareToIgnoreCase(bici.pmodelo) == 0 && this.pcolor.compareToIgnoreCase(bici.pcolor) == 0 );
};
public Boolean Getbici(Bicicleteria a,Bicicleteria b){
return a.equals(b);
};
@Override
public int hashCode(){
int d = 3;
GregorianCalendar fecha = new GregorianCalendar();
int c = fecha.get(Calendar.SECOND);
int a = d*( Getpmarca().compareTo(Getpmodelo()) + Getpmodelo().compareTo(Getpcolor()))+ c;
return a ;
};
Object o = null ;
@Override
public String toString(){
return
" Marca: " + pmarca + " Modelo: " + pmodelo + " Color: " + pcolor + " precio: " + String.format("%.2f%n",pprecio);
};
public static void main(String[] args) {
Bicicleteria bicicleta1 = new Bicicleteria("a", "a", "a");
Bicicleteria bicicleta2 = new Bicicleteria("a","a","a");
Bicicleteria bicicleta3 = new Bicicleteria("a","f","g");
// System.out.println  (fech.LongDateTime());
System.out.println(bicicleta1.pmarca); System.out.println(bicicleta1.pmodelo);
System.out.println(bicicleta1.pcolor);
System.out.println(bicicleta1.pcantidad); System.out.println(bicicleta1.pdisponible);  
System.out.println(bicicleta1.pcontador);
System.out.println(bicicleta2.pmarca);
System.out.println(bicicleta2.pcontador);
System.out.println(bicicleta1.equals (bicicleta2));
System.out.println(bicicleta2.equals(bicicleta3));
System.out.println(bicicleta1);
System.out.println("hashCode1: " + bicicleta1.hashCode());
System.out.println(bicicleta2);
System.out.println("hashCode2: " + bicicleta2.hashCode());
System.out.println(bicicleta3);
System.out.println("hashCode3: " + bicicleta3.hashCode());;
GregorianCalendar df = new  GregorianCalendar();
System.out.println  (df);
System.out.println( df.get(Calendar.SECOND));
}
}
package pruebajava;
import java.util.*;
import pruebajava.Bicicleteria;
public class Navbicicleteria extends Bicicleteria  implements Comparator<Bicicleteria>{
@Override
public int compare(Bicicleteria o1 , Bicicleteria o2)
{
if ((!((o1 instanceof Bicicleteria)
&&  (o2 instanceof Bicicleteria)))|| (o1 == null) || (o2 == null)) {return -1;};
if (o1 == o2){return 0;};
Bicicleteria bici1 = (Bicicleteria) o1;
Bicicleteria bici2 = (Bicicleteria) o2;
return (bici1.Getpmarca().compareToIgnoreCase(bici2.Getpmarca()) + bici1.Getpmodelo().compareToIgnoreCase(bici2.Getpmodelo()) + bici1.Getpcolor().compareToIgnoreCase (bici2.Getpcolor()));
};
@Override
public  boolean equals(Object o){
 if (!(o instanceof Bicicleteria) || o== null ) {return false ;};
 if (this == o){
   return true;
};  
 Bicicleteria bici = (Bicicleteria) o;
return
(this.pmarca.compareToIgnoreCase(bici.pmarca) == 0 && this.pmodelo.compareToIgnoreCase(bici.pmodelo) == 0 && this.pcolor.compareToIgnoreCase(bici.pcolor) == 0 );
};
public Boolean Getbici(Bicicleteria a,Bicicleteria b){
return a.equals(b);
};
@Override
public int hashCode(){
int d = 3;
GregorianCalendar fecha = new GregorianCalendar();
int c = fecha.get(Calendar.SECOND);
int a = d*( Getpmarca().compareTo(Getpmodelo()) + Getpmodelo().compareTo(Getpcolor()))+ c;
return a ;
};
Object o = null ;
@Override
public String toString(){
return
" Marca: " + pmarca + " Modelo: " + pmodelo + " Color: " + pcolor + " precio: " + String.format("%.2f%n",pprecio)  ;
};
//public static void main(String[] args) {
static NavigableSet<Bicicleteria> navigablebiciset= new TreeSet<>(new Navbicicleteria());
static public void precioCambiado(){System.out.println("Precio modificado");};
static public void biciInexiste(){System.out.println("Tipo de bicicleta inexistente");};
static public void CambioPrecio( String pmarca, String pmodelo,String pcolor, double newprecio ){
Bicicleteria getbici= new Bicicleteria (pmarca ,pmodelo , pcolor );
if ((!(navigablebiciset.ceiling(getbici)==null)) &&
(navigablebiciset.ceiling(getbici).equals(getbici)==true)){ navigablebiciset.ceiling(getbici).pprecio = newprecio;
precioCambiado();}
else {biciInexiste();};
getbici = null;
};
static public void cantCambiada(){
 System.out.println("Cantidad de bicicletas cambiada");
};
static public void Cambiocantidad( String pmarca, String pmodelo, String pcolor, int newcantidad){
Bicicleteria getbici = new Bicicleteria(pmarca,pmodelo,pcolor);
if((!(navigablebiciset.ceiling(getbici)==null)&& (navigablebiciset.ceiling(getbici).equals(getbici)==true))){navigablebiciset.ceiling(getbici).pcantidad = newcantidad;
cantCambiada();}
else{ biciInexiste();};
getbici = null;
};
public static void main(String[] args){
navigablebiciset.add(new Bicicleteria("a", "b", "c"));
navigablebiciset.add(new Bicicleteria("d", "e", "f"));
navigablebiciset.add(new Bicicleteria("a", "b", "c"));
System.out.println(navigablebiciset);
CambioPrecio("d","e","f",20000);
System.out.println("nuevoprecio: ");
System.out.println(navigablebiciset);
}
}

5 days ago

dario lobos wrote:

dario lobos wrote:

Carey Brown wrote:Or TreeSet if you want them in sorted order.



dario lobos wrote:

dario lobos wrote:

Carey Brown wrote:Or TreeSet if you want them in sorted order.



If someone know where i can find information to how implement the treeset with this object and how can add this date and time in the constructor let me know.

Also i overrite the methods equal and hashcode both work and are congruents (compare, equal and hashcode) but i dont know how i must to use it in the treeset in the navigable sorted set or it the system use them internally. in the constructor i think that i must to use only comparator compare... well any help to this is wellcome. I am starting. I dindt know nothing about programing 20 days ago...

thanks.

Dario

1 week ago