• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

executing the program.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I created 3 classes + one main class. (sorry again, it's all in french !! French java class)
I have a class named Journee (Day), another one named Billet (ticket) and another on called Facture(billing) and the main class is called Safari.

I believe that my Journee and Billet class are ok
and even thought I'm able to compile the Facture class, I guess there is something missing.

The main class Safari should be able to get the info from Facture,

When I execute the program I'm able to write down the day and how many tickets but after entering the tickets it should be able to make the calculation but it's not the case.

What is wrong and how can I write it down ??

Here's all my info

1- Class (Journee)
public class Journee {

// Autres m�thodes s'il y a lieu
public static final String LU = "lundi";
public static final String MA = "mardi";
public static final String ME = "mercredi";
public static final String JE = "jeudi";
public static final String VE = "vendredi";
public static final String SA = "samedi";
public static final String DI = "dimanche";
// variable(s) d'instance s'il y a lieu (attributs)
private String jourDeLaSemaine; //lu= lundi, ma...

// constructeur(s) s'il y a lieu
public Journee(String jourDeLaSemaine){
this.jourDeLaSemaine = jourDeLaSemaine;
}


// m�thode(s) d'instance s'il y a lieu
//getters-setters
public String getJourDeLaSemaine(String jourDeLaSemaine){
return new String(jourDeLaSemaine);
}

public void setJourDeLaSemaine(String jourSemaine){
jourDeLaSemaine= new String(jourSemaine);
}

public boolean estFinDeSemaine(){
return (jourDeLaSemaine.compareTo(SA)==0) ||
(jourDeLaSemaine.compareTo(DI)==0);

}

public boolean estJourneeValide(){
return (jourDeLaSemaine.compareTo(LU)==0) ||
(jourDeLaSemaine.compareTo(MA)==0)||
(jourDeLaSemaine.compareTo(ME)==0) ||
(jourDeLaSemaine.compareTo(JE)==0)||
(jourDeLaSemaine.compareTo(VE)==0) ||
(jourDeLaSemaine.compareTo(SA)==0) ||
(jourDeLaSemaine.compareTo(DI)==0);

}
} // journ�e

2- Class (Billet)

public class Billets {



// Autres m�thodes s'il y a lieu
public static final double prixSemaineEnfant = 10.0;
public static final double prixFinSemaineEnfant = 13.0;

public static final double prixSemaineEtudiant = 17.0;
public static final double prixFinSemaineEtudiant = 19.0;

public static final double prixSemaineAdulte = 26.0;
public static final double prixFinSemaineAdulte = 29.0;

public static final double prixSemaineAgeOr = 19.0;
public static final double prixFinSemaineAgeOr = 21.0;

public static final double prixSemaineFamille = 65.0;
public static final double prixFinSemaineFamille = 76.0;

public static final int nombreBilletMax = 500;
// variable(s) d'instance s'il y a lieu (attributs)
private int nombreBilletEnfant; // nombre de billets pour le groupe �ge enfant
private int nombreBilletEtudiant; // nombre de billets pour le groupe �ge �tudiant
private int nombreBilletAdulte; // nombre de billets pour le groupe �ge adulte
private int nombreBilletAgeOr; // nombre de billets pour le groupe �ge d'or


// constructeur(s) s'il y a lieu
public Billets( int nombreBilletEnfant, int nombreBilletEtudiant,
int nombreBilletAdulte, int nombreBilletAgeOr){

//initialisation des variables
this.nombreBilletEnfant = nombreBilletEnfant; //
this.nombreBilletEtudiant = nombreBilletEtudiant; //
this.nombreBilletAdulte = nombreBilletAdulte; //
this.nombreBilletAgeOr = nombreBilletAgeOr;



}

// m�thode(s) d'instance s'il y a lieu
//getters-setters

public boolean verifierBilletsDisponibles(int nombreTotalBilletsVendus){
int nombreBilletsDisponible;


nombreTotalBilletsVendus = this.nombreBilletEnfant +
this.nombreBilletEtudiant +
this.nombreBilletAdulte +
this.nombreBilletAgeOr;

nombreBilletsDisponible = nombreBilletMax -
nombreTotalBilletsVendus;




return nombreBilletMax - nombreTotalBilletsVendus > 0;

}
public int getNombreBilletEnfant() {
return nombreBilletEnfant;
}

public int getNombreBilletEtudiant() {
return nombreBilletEtudiant;
}
public int getNombreBilletAdulte() {
return nombreBilletAdulte;
}

public int getNombreBilletAgeOr() {
return nombreBilletAgeOr;
}
public void setNombreBilletEnfant() {
this.nombreBilletEnfant = nombreBilletEnfant ;
}

public void setNombreBilletEtudiant() {
this.nombreBilletEtudiant = nombreBilletEtudiant ;
}
public void setNombreBilletAdulte() {
this.nombreBilletAdulte = nombreBilletAdulte;
}

public void setNombreBilletAgeOr() {
this.nombreBilletAgeOr = nombreBilletAgeOr;
}

public void calculerNombreBilletsAchetes (){
int nombreTotalBilletsVendus;
nombreTotalBilletsVendus = this.nombreBilletEnfant +
this.nombreBilletEtudiant +
this.nombreBilletAdulte +
this.nombreBilletAgeOr;
}




} // billets

3- Class (Facture)

public class Facture {

final String SA = "samedi";
final String DI = "dimanche";
int nombreBilletEnfant; // nombre de billets pour le groupe �ge enfant
int nombreBilletEtudiant; // nombre de billets pour le groupe �ge �tudiant
int nombreBilletAdulte; // nombre de billets pour le groupe �ge adulte
int nombreBilletAgeOr; // nombre

// Autres m�thodes s'il y a lieu
// membres de classe
public static final double tauxTps = 0.07;
public static final double tauxTvq = 0.075;



// membres d'instance
private Journee journee;// contient toutes les informations sur le jour de la visite
private Billets billet; // contient toutes les informations sur les billets
private double montantVente; // repr�sente le montant de vente avant taxes
private double montantTps; // repr�sente le montant de la taxe TPS
private double montantTvq; // repr�sente le montant de la taxe TVQ double
private double montantTotal; // repr�sente le montant total

//constructeur
public Facture(Journee journee, Billets billet){
this.journee = journee;
this.billet = billet;
double montantVente = 0;
double montantTps = 0;
double montantTvq = 0;
double montantTotal = 0;

}
//methodes d'instance





public void calculerMontantAvantTaxe(){

if ( journee.estFinDeSemaine()) {
montantVente = billet.getNombreBilletEnfant() * billet.prixFinSemaineEnfant +
billet.getNombreBilletEtudiant() * billet.prixFinSemaineEtudiant +
billet.getNombreBilletAdulte() *billet.prixFinSemaineAdulte +
billet.getNombreBilletAgeOr() * billet.prixFinSemaineAgeOr ;
}
}

public void calculerMontantTps(){

montantTps = montantVente * tauxTps;
}
public void calculerMontantTvq(){

montantTvq =( montantVente + montantTps) * tauxTvq ;
}
public void calculerMontantTotal(){
montantTotal = montantVente +
montantTps +
montantTvq;
}




public void afficher(){

System.out.print("\n\nLe montant vente est : ");
System.out.println(montantVente);

System.out.print("\n\nLe montant TPS est : ");
System.out.println(montantTps);

System.out.print("\n\nLe montant TVQ est : ");
System.out.println(montantTvq);

System.out.print("\n\nLe montant total est : ");
System.out.println(montantTotal);
System.out.println();

billet.calculerNombreBilletsAchetes ();





}





} // facture

And Finaly

the Main class

public class Safari {
static void presenterLogiciel(){
System.out.println("bienvenue au parc safari");
System.out.println("ce logiciel permet de calculer la facture de billets d'entr�e au parc");
System.out.println("r�alis� par Ait kerrane Redouane");
System.out.println("versin:1.01");
System.out.println();
}// fin de presenterLogiciel





public static void main (String[] params) {



//d�claration des variables

int nombreBilletsEnfant =0;
int nombreBilletsEtudiant =0;
int nombreBilletsAdulte =0;
int nombreBilletsAgeOr =0;
int nombreTotalDeBilletsVendus=0;
int nombreDeBilletsDisponible= 0;
double montantBillets =0;
double montantTotalFacture=0;
double tps=0;
double tvq=0;
Billets billet;
//billet = new Billets();
char Reponse ;
String jourSemaine ;


//d�but
// appel de la m�thode
presenterLogiciel();


do
{
//bloc de saisie






int Entree1 = 0;
int Entree2 = 0;
int Entree3 = 0;
int Entree4 = 0;




System.out.println("entrez le jour de la semaine:");
jourSemaine =Clavier.lireString();

//billet.verifierBilletsDisponibles();


while(true){
try{
System.out.println("Entrez le nombre de billets Enfant(10 ans et moins):");
Entree1 = Clavier.lireInt();
nombreBilletsEnfant = nombreBilletsEnfant + Entree1;

//nombreBilletsEnfant = billet.getNombreBilletEnfant(); //
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}
while(true){
try{
System.out.println("Entrez le nombre de billets Etudiant(11 � 17 ans):");
Entree2 = Clavier.lireInt();
nombreBilletsEtudiant = nombreBilletsEtudiant + Entree2;
// nombreBilletsEtudiant = billet.getNombreBilletEtudiant();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}

while(true){
try{
System.out.println("Entrez le nombre de billets Adulte(18 � 64 ans):");
Entree3 = Clavier.lireInt();
nombreBilletsAdulte = nombreBilletsAdulte + Entree3;
//nombreBilletsAdulte = billet.getNombreBilletAdulte();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}

while(true){
try{
System.out.println("Entrez le nombre de billets Age or(65 ans et plus):");
Entree4 = Clavier.lireInt();
nombreBilletsAgeOr = nombreBilletsAgeOr + Entree4;
//nombreBilletsAgeOr = billet.getNombreBilletAgeOr();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}
billet = new Billets(nombreBilletsEnfant,nombreBilletsEtudiant,nombreBilletsAdulte,nombreBilletsAgeOr);


//bloc de traitement

//d�terminer le prix unitaire de chaque cat�gorie de billetsen fonction de jour de la semaine

//jour de la semaine(du lundi au vendredi)



//bloc d'affichage


SimpleDateFormat formatDate = new SimpleDateFormat("dd-MM-yyyy"); // format de date
Date dateSysteme = new Date();// Cr�ation d'un objet date

System.out.print(" La date : ");// La date du syst�me
System.out.println(formatDate.format(dateSysteme));
System.out.println();

System.out.println("Voulez-vous continuer(y/n)?");
Reponse = Clavier.lireChar();




} while((Reponse == 'y' || Reponse == 'Y'));

}
// main

} // Safari



Thanks
Ed
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eddy,

I gave it a shot, and took a look at the Main class to figure out what
was happening - but without success.

As I understand it, your problem is that you can't calculate something
(the total cost of the tickets?), and you wish to store this amount - correct?

A few pointers:

1. dont copy/past so much code - it's very hard to read. And when you
insert code, then use the [ code ] ... [/ code] tags, e.g.:


2. rename your method ect. to english - it makes it alot easier for read
(for us, that is)

3. please explain what your program does.. and if you think the other
classes are ok, then simply explain the "public interface" of those classes
for example:

Class Ticket
+ constructor: Ticket(int amount) // creates x tickets
+ setChildTicket() // this will set the tickets as children tickets, which costs 10 $ a piece
+ makeAdultTicket() // this will set the tickets as adult tickets, which costs 20 $ a piece
+ getTickets() //retuns the number of tickets

and then simply show the static void main(...) method

edit: 4. you could also insert what you'd get as output when you run the
program, then it's abit easier to deduct the flow..


Hope it helped..

/Svend Rost
[ December 10, 2005: Message edited by: Svend Rost ]
 
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic