Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to add this java code assignment to my NETBEANS program and it is gi

ID: 670107 • Letter: I

Question

I am trying to add this java code assignment to my NETBEANS program and it is given me an error. A tutor assisted me with the code but I am having complications with the actual program itself running it. (NETBEANS). Can or will someone here send me a test project through NETBEANS as a solution/ answer so I can learn or see the accurate version of the project in NETBEANS?

import java.io.*;
import java.util.*;

class Ticket{
Long number;
String category;
String holder;
Date date;
double price;
boolean status;
Random rand;
public Ticket(String c,String h,Date d,double p,boolean b){
rand = new Random();
number = rand.nextLong();
category = c;
holder = h;
date = d;
price = p;
status = b;
}
void setPrice(double p){
price = p;
}
void changePurchaseStatus(boolean newStatus){
status = newStatus;
}
Long getNumber(){
return number;
}
String getCategory(){
return category;
}
String getHolder(){
return holder;
}
String getDate(){
return date.toString();
}
double getPrice(){
return price;
}
@Override
public String toString(){
return "";
}
}

class Merchandise{
Long ID;
String category;
String description;
double price;
boolean instock;
Random rand;
public Merchandise(String c,String d,double p,boolean in){
rand = new Random();
ID = rand.nextLong();
category = c;
description = d;
price = p;
instock = in;
}

void setPrice(double p){
price = p;
}
void setInstock(boolean b){
instock = b;
}
String getId(){
return String.valueOf(ID);
}
String getCategory(){
return category;
}
String getDescription(){
return description;
}
double getPrice(){
return price;
}
boolean getInstock(){
return instock;
}
@Override
public String toString(){
return "";
}
}

class AmusementPark{
ArrayList<Ticket> tickets;
ArrayList<Merchandise> merchandise;
String name;
public AmusementPark(String n){
tickets = new ArrayList<Ticket>();
merchandise = new ArrayList<Merchandise>();
name = n;
}
String getName(){
return name;
}
ArrayList<Date> getTicketDates(){
ArrayList<Date> temp = new ArrayList<Date>();
for (int i = 0; i < tickets.size(); i++)
temp.add(tickets.get(i).date);
return temp;
}
int getTickets(Date date){
int count = 0;
for (int i = 0; i < tickets.size(); i++){
if (date.compareTo(tickets.get(i).date) == 0)
count++;
}
return count;
}
Ticket getTicket(Long id){
for (int i = 0; i < tickets.size(); i++){
if (id.compareTo(tickets.get(i).number) == 0)
return tickets.get(i);
}
return null;
}
ArrayList<Merchandise> getMerchandise(){
return merchandise;
}
ArrayList<Merchandise> getMerchandise(String category){
ArrayList<Merchandise> temp = new ArrayList<Merchandise>();
for (int i = 0; i < merchandise.size(); i++){
if (merchandise.get(i).category.compareTo(category) == 0)
temp.add(merchandise.get(i));
}
return temp;
}
Merchandise getMerchandise(Long id){
for (int i = 0; i < merchandise.size(); i++){
if (merchandise.get(i).ID.compareTo(id) == 0)
return merchandise.get(i);
}
return null;
}
void addTicket(Ticket t){
tickets.add(t);
}
void addMerchandise(Merchandise m){
merchandise.add(m);
}
void buyMerchandise(String id){
Long l = new Long(id);
Merchandise m = getMerchandise(l);
if (m != null)
merchandise.remove(m);
else
System.out.println("No such ID exist");
}
void buyTicket(String id){
Long l = new Long(id);
Ticket tic = getTicket(l);
if (tic != null)
tickets.remove(tic);
else
System.out.println("No such ID exist");
}
}

Please feel free to share your email address so you can send me the file if necessary for a better view in NETBEANS.

THANKS!!!

Explanation / Answer

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;

public class Tester
{
public static void main(String[] args)
{
   Date d=new Date("14/11/1993");
AmusementPark p=new AmusementPark("manikanta");
Ticket t=new Ticket("high", "kante",d, 14, true);
Merchandise m=new Merchandise("books", "good one in market", 32, true);
p.addTicket(t);
p.addMerchandise(m);
ArrayList<Date> k=p.getTicketDates();
System.out.println(p.getTicket(t.getNumber()).holder);

  
}
}

In this way the tester program will be defined and if you provide question i can do better.at email nelloremanikanta@yahoo.com

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote