Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,161,503 members, 7,847,080 topics. Date: Saturday, 01 June 2024 at 10:38 AM

A Program For A Ticket Sales Point. Urgent Please! - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / A Program For A Ticket Sales Point. Urgent Please! (2635 Views)

Matlab: A Program For Mathematicians? / A Program To Tell Ur Zodiac Sign / [problem] Write A Program In C++ That Finds The Hcf Of 2 Numbers Without Using A Recursive Function (2) (3) (4)

(1) (Reply) (Go Down)

A Program For A Ticket Sales Point. Urgent Please! by mikkytrio(m): 12:23am On May 22, 2009
please am a student that needs some java problem solution, the first question is in java when you create classes do you save them all in the same file with the main(String[] args) as you do with user defined functions in c# and main()?. The second is that i have another code to write that requires me to write a program for a ticket sales point.

Class name: ticket
Attributes:
Ticket type (VIP, ECON, NORM): string
Ticket price: double
Event time: string
Ticket code: string

1. Create 4 objects from ticket class.
2. Find total number of sold tickets
3. Find total price of sold tickets
4. List all 4 objects in the following order

Ticket code:
Ticket type:
Ticket price:
Event time:

Constraints
a) Ticket code has to be in the following format
Int-ticket type
10:VIP; 20: NORM; 30: ECON Char- PLACE OF EVENT ROW NUMBER-LESS THAN 40(INT) SEAT NUMBER-LESS THAN 20(INT)

please can anyone help?
Re: A Program For A Ticket Sales Point. Urgent Please! by bigboyslim(m): 1:39am On May 22, 2009
Its advisable to save classes in different files but all classes should be in the same package. the main() class in particular should be saved in a separate file. (this is just good programming practice anyway, if you save them all in one file, the program will still run)

What is the problem you have with the ticket sales point. Try to be more specific. I'm not sure anyone is going to be willing to write the entire program for you. Try and point out what you are having difficulties with, then maybe someone might be able to help.
Re: A Program For A Ticket Sales Point. Urgent Please! by mikkytrio(m): 5:30pm On May 22, 2009
Though the question doesn't really make much meaning to me in a way, but this is my code in full


ticketTest.java



public class ticketTest
{

public static void main(String[] args)
{
tickets harrysBuying = new tickets();
harrysBuying.ticketCode(10);
System.out.print("Ticket Code: "wink;
System.out.println(harrysBuying.codes());
System.out.print("Ticket Type: "wink;
System.out.println(harrysBuying.ticketType());
System.out.print("Ticket Price: "wink;
System.out.println(harrysBuying.ticketPrice());

}
}


/*
* A ticket sales point program that calculates the price of toal sold tickets
* toatal amount of tickets sold and the type of tickets sold
*/


public class tickets
{
/*
* Displays the type of ticket
* @param ticket code
*/

public void ticketCode(double number)
{
if(number == 10)
{
ticket = "VIP";
price = 100;
code = "10";
}

else
{
if (number == 20)
{
ticket = "ECO";
price = 50;
code = "20";
}
else
{
ticket = "NORM";
price = 25;
code = "30";
}
}
}

/*
* @retun the ticket type
*/

public String ticketType()
{
return ticket;
}

/*
* @return ticket code
*/

public String codes()
{
return code;
}



/*
*this gets the price of the price of the current ticket
* @retun the ticket price
*/

public double ticketPrice()
{
return price;
}

private double price;
private String ticket;
private String code;

}
Re: A Program For A Ticket Sales Point. Urgent Please! by nolongTing: 9:46am On May 23, 2009
mikkytrio:

please am a student that needs some java problem solution, the first question is in java when you create classes do you save them all in the same file with the main(String[] args) as you do with user defined functions in c# and main()?. The second is that i have another code to write that requires me to write a program for a ticket sales point.

Class name: ticket
Attributes:
Ticket type (VIP, ECON, NORM): string
Ticket price: double
Event time: string
Ticket code: string

1. Create 4 objects from ticket class.
2. Find total number of sold tickets
3. Find total price of sold tickets
4. List all 4 objects in the following order

Ticket code:
Ticket type:
Ticket price:
Event time:

Constraints
a) Ticket code has to be in the following format
Int-ticket type
10:VIP; 20: NORM; 30: ECON Char- PLACE OF EVENT ROW NUMBER-LESS THAN 40(INT) SEAT NUMBER-LESS THAN 20(INT)

please can anyone help?




My advice to you is study  OOP theory first! Then things will become alot easier.  You can create "inner classes" which can be either instance or static; you can even create anonymous classes.  When, to create these classes is all down to design.  No you cannot save two discrete classes in the same file in Java. But in this example all you have to do create two SEPERATE classes ticketTest.java and tickets.java and it should run.


Create tickets.java seperately with
/*
* A ticket sales point program that calculates the price of toal sold tickets
* toatal amount of tickets sold and the type of tickets sold
*/


public class tickets
{
/*Code goes here*/
   
}

------------------------------------------------------------------------------
Now create ticketTest.java seperately with


public class ticketTest
{

   public static void main(String[] args)
   {
    /*Your code here*/
   
   }
}
Re: A Program For A Ticket Sales Point. Urgent Please! by Ghenghis(m): 5:40pm On May 23, 2009
bigboyslim:

Its advisable to save classes in different files but all classes should be in the same package. the main() class in particular should be saved in a separate file. (this is just good programming practice anyway, if you save them all in one file, the program will still run)

Why would you want to make all your classes in the same package ? The package structure should reflect the logical arrangement of the classes.


Also you can have only one public class in a translational unit (i.e .java file), the other classes would be package private(meaning no modifier).

Like @nolongTing said , invest a little more time in the basic before you bite on this kind of project you're undertaking ,
It doesn't seem difficult, but that's for someone who knows Java(or .NET).


Cheers
Re: A Program For A Ticket Sales Point. Urgent Please! by mikkytrio(m): 11:56pm On May 23, 2009
thanks for the various contributions. The code i pasted above was it not good enough?
Re: A Program For A Ticket Sales Point. Urgent Please! by carliecode(m): 10:52am On May 25, 2009
mikkytrio:

when you create classes do you save them all in the same file with the main(String[] args) as you do with user defined functions in c# and main()?.

I wish to point out to you that in C# and other Microsoft .Net languagues like Vb.net , J# and F#, you do not have to save all your classes in the same file as you seem to have implied in quote above.

Dotnet is so flexible that it also introduces Partial Classes. ie you have even have different sections of a single class existing in different code files.
Going to you question, my response as an experienced OOP Engineer is that seperate your classes into different files, let all your classes for a a particular project be in a common assembly ie packages in Java. This will make versoning easy and also help you in code modification and reuse

(1) (Reply)

Java online compiler for swing programs / Suitable Processor For Programming / Why You Have To Learn Python Programming In 2020: Get Free Ebooks

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 27
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.