how to create a method put winecaseback - java

Hi guys i have created a browser class for my my project , i have created a method called select winecase which selects a winecase, however i am unsure how to
create a method putwinecaseback, which removes the wincase from the shopping basket by calling the method showBasket()
/**
* Write a description of class Browser here.
*
* #author (johnson)
* #version (10/12/13)
*/
import java.util.ArrayList;
import java.util.List;
public class Browser
{
// instance variables - replace the example below with your own
private int iD;
private String email;
private int yearOfBirth;
private boolean memberID;
private WineCase wineCase;
private boolean loggedIn;
private Website website;
private boolean discount;
private List<Boolean> baskets = new ArrayList<Boolean>();
/**
* Constructor for objects of class Browser
*/
public Browser()
{
// initialise instance variables
wineCase = null;
website = null;
iD = 00065;
yearOfBirth = 1992;
memberID = true;
discount = false;
}
/**
* Constructor for objects of class Browser
*/
public Browser(String newEmail,int newYearOfBirth)
{
// initialise instance variables
wineCase = null;
website = null;
iD = 0;
email = newEmail;
yearOfBirth = newYearOfBirth;
loggedIn = false;
memberID = true;
discount = false;
}
/**
* Constructor for objects of class Browser
*/
public Browser(int newID, String newEmail,int newYearOfBirth)
{
// initialise instance variables
wineCase = null;
website = null;
iD = newID;
email = newEmail;
yearOfBirth = newYearOfBirth;
memberID = true;
discount = false;
}
/**
* returns the ID
*/
public int getId()
{
return iD;
}
/**
* gets the email of the browser class
*/
public String getEmail()
{
return email;
}
public boolean getDiscount()
{
return discount;
}
/**
* gets the yearOfBirth for the browser class
*/
public int yearOfBirth()
{
return yearOfBirth;
}
public double getWineCost()
{
return wineCase.getWineCost();
}
public double getWineCase()
{
return wineCase.getWineCost();
}
/**
* returns
*/
public void setLoginStatus(boolean status)
{
loggedIn = status;
}
/**
* returns
*/
public void selectWineCase(WineCase winecase)
{
wineCase = winecase;
System.out.println ("Browser "+getId()+" has selcted wine case"+wineCase.getRefNo()+ "of "+winecase.getNoOfBottles()+ wineCase.getDescription()+ " at £"+wineCase.getWineCost());
}
/**
* returns
*/
public void payForWine()
{
website.checkout(this);
}
public void setId()
{
iD = 999;
}
public void setWebSite(Website website)
{
this.website = website;
}
public void setDiscount(boolean discount)
{
this.discount = discount;
}
showBasket()
int counter = 8;
int inc = 1;
while ( counter <= 18 )
{
System.out.print ( " " + counter );
if ( counter >= 14 && counter < 18 )
{
System.out.print ( " hello " );
}
counter = counter + inc;
inc += 1;
}
public ArrayList<WineCase> getBasket(WineCase wineCase)
{
this.wineCase = wineCase;
System.out.println ("Browser "+getId()+" has selcted wine case"+wineCase.getRefNo()+ "of "+wineCase.getNoOfBottles()+ wineCase.getDescription()+ " at £"+wineCase.getWineCost());
}
}
any answers/replies would be greatly appreciated as i am confused.

For this question. Write your putwineCase() method like this:
public void putwineCase()
{
/**
Your logic here
**/
}
This will work. Thankyou.

Related

Cannot find symbol - class InventoryItem

I re-type these code from a book and somehow I got error " Cannot find symbol - class InventoryItem "
import java.util.Scanner;
public class ReturnObject {
public static void main(String[] args) {
InventoryItem item;
item = getData();
System.out.println("Des: " + item.getDescription() + " Unit: " +
item.Units());
}
public static InventoryItem getData() {
String desc;
int units;
Scanner keyboard = new Scanner(System.in);
System.out.print("enter descri: ");
desc = keyboard.nextLine();
System.out.print("number of unit: ");
units = keyboard.nextInt();
return new InventoryItem(desc, units);
}
}
I'm new to java please help
thank you.
I think this should be the InventoryItem you need.
/**
* This class uses three constructors.
*/
public class InventoryItem {
private String description; // Item description
private int units; // Units on-hand
/**
* No-arg constructor
*/
public InventoryItem() {
description = "";
units = 0;
}
/**
* The following constructor accepts a
* String argument that is assigned to the
* description field.
*/
public InventoryItem(String d) {
description = d;
units = 0;
}
/**
* The following constructor accepts a
* String argument that is assigned to the
* description field, and an int argument
* that is assigned to the units field.
*/
public InventoryItem(String d, int u) {
description = d;
units = u;
}
/**
* The setDescription method assigns its
* argument to the description field.
*/
public void setDescription(String d) {
description = d;
}
/**
* The setUnits method assigns its argument
* to the units field.
*/
public void setUnits(int u) {
units = u;
}
/**
* The getDescription method returns the
* value in the description field.
*/
public String getDescription() {
return description;
}
/**
* The getUnits method returns the value in
* the units field.
*/
public int getUnits() {
return units;
}
}
complete example click here and here
The class you are currently in cannot find the class (symbol) InventoryItem. You need to define this class & the getData method.
public class InventoryItem{
private String desc;
private int units;
public InventoryItem(){
Scanner keyboard = new Scanner(System.in);
System.out.print("enter descri: ");
desc = keyboard.nextLine();
System.out.print("number of unit: ");
units = keyboard.nextInt();
}
public static InventoryItem getData() {
return this;
}
}
maybe your InventoryItemclass:
public class InventoryItem {
private String desc;
private int units;
public InventoryItem(String desc, int units) {
this.desc=desc;
this.units=units;
}
public String getDescription() {
return desc;
}
public int Units() {
return units;
}
}

Creating an array with 3 variables

I am trying to create an array of students which will contain 3 different types of students and each of the students will have 3 variables name, and 2 grades.
This is what I have done so far, and it gives me the following error cannot find symbol.
Main class:
public class JavaLab5 {
public static final int DEBUG = 0;
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
Student s[] = new Student[10];
s[0] = new MathStudent(Smith,14,15);
s[1] = new MathStudent(Jack,16,19);
s[2] = new MathStudent(Victor,18,21);
s[3] = new MathStudent(Mike,23,28);
s[4] = new ScienceStudent(Dave,32,25);
s[5] = new ScienceStudent(Oscar,28,56);
s[6] = new ScienceStudent(Peter,29,28);
s[7] = new ComputerStudent(Philip,25,38);
s[8] = new ComputerStudent(Shaun,34,39);
s[9] = new ComputerStudent(Scott,45,56);
for (int loop = 0; loop < 10; loop++) {
System.out.println(s[loop].getSubjects());
System.out.print(loop + " >>" + s[loop]);
}
}
}
This is the Student class:
public class Student {
private String name;
//private int age;
//public String gender = "na";
public static int instances = 0;
// Getters
//public int getAge() {
//return this.age;
//}
public String getName() {
return this.name;
}
// Setters
//public void setAge(int age) {
//this.age = age;
//}
public void setName(String name) {
if (JavaLab5.DEBUG > 3) System.out.println("In Student.setName. Name = "+ name);
this.name = name;
}
/**
* Default constructor. Populates name,age and gender
* with defaults
*/
public Student() {
instances++;
//this.age = 18;
this.name = "Not Set";
//this.gender = "Not Set";
}
/**
* Constructor with parameters
* #param age integer
* #param name String with the name
*/
public Student(String name) {
//this.age = age;
this.name = name;
}
/**
* Gender constructor
* #param gender
*/
//public Student(String gender) {
//this(); // Must be the first line!
//this.gender = gender;
//}
/**
* Destructor
* #throws Throwable
*/
protected void finalize() throws Throwable {
//do finalization here
instances--;
super.finalize(); //not necessary if extending Object.
}
public String toString () {
return "Name: " + this.name; //+ " Age: " + this.age + " Gender: "
//+ this.gender;
}
public String getSubjects() {
return this.getSubjects();
}
}
and this is the MathStudent class which inherits from the Student class:
public class MathStudent extends Student {
private float algebraGrade;
private float calculusGrade;
/**
* Default constructor
* #param name
* #param algebraGrade
* #param calculusGrade
*/
public MathStudent(String name, float algebraGrade, float calculusGrade) {
super();
this.algebraGrade = algebraGrade;
this.calculusGrade = calculusGrade;
}
public MathStudent() {
super();
algebraGrade = 6;
calculusGrade = 4;
}
// Getters
public void setAlgebraGrade(float algebraGrade){
this.algebraGrade = algebraGrade;
}
public void setCalculusGrade(float calculusGrade){
this.calculusGrade = calculusGrade;
}
// Setters
public float getAlgebraGrade() {
return this.algebraGrade;
}
public float getCalculusGrade() {
return this.calculusGrade;
}
/**
* Display information about the subject
* #return
*/
#Override
public String getSubjects(){
return(" Math Student >> " + "Algebra Grade: " + algebraGrade
+ " Calculus Grade: " + calculusGrade);
}
}
Check how you instantiate students, i.e.
new MathStudent(Smith,14,15);
The name should be in quotes like "Smith"
new MathStudent("Smith",14,15);
Otherwise Smith will be interpreted as variable and this one is not defined.

How to create a set enum method (java)

I'm very new to object oriented programming and am trying to create a library system simulation. I'm trying to create set methods which:
set the status of the library book as REFERENCE_ONLY (enum)
Set the status of the library book as AVAILABLE_FOR_LENDING (enum)
A boolean which decides if the book is ON_LOAN (enum)
My code:
public class LibrarySimulation {
public static void main(String[] args) {
}
public static String getBookAuthor(){
return null;
}
}
class LibraryBook {
public enum status {REFERENCE_ONLY, ON_LOAN, AVAILABLE_FOR_LENDING};
String bookAuthor;
String bookTitle;
int bookPages;
String classification;
int timesBorrowed;
int reservations;
static int totalOnLoan;
/**
* Constructor with arguments for a LibraryBook’s author(s),
* title and number of pages
* #param bookAuthor the names of the author(s) of this
* LibraryBook
* #param bookTitle the title of this LibraryBook
* #param bookPages the number of pages of this
* LibraryBook
*/
public LibraryBook(String bookAuthor,String bookTitle, int bookPages){
bookAuthor = null;
bookTitle = null;
bookPages = 0;
}
/**
* A method to reset the Library classification of this
* LibraryBook
* #param bookClass the proposed new classification
* #return true, if the proposed new
* classification has at
* least 3 characters to which
* the Library classification is
* reset.
* false, otherwise.
*/
public boolean setClassification(String bookClass){
if(bookClass.length() >= 3){
return false;
}
else{
return true;
}
}
public String setAsReferenceOnly(){
LibraryBook book = new LibraryBook(status.REFERENCE_ONLY);
}
//method for getting bookAuthor
public String getBookAuthor(){
return bookAuthor;
}
//method for getting bookTitle
public String getBookTitle(){
return bookTitle;
}
//method for getting bookPages
public int getBookPages(){
return bookPages;
}
//method for getting classification
public String getClassification(){
return classification;
}
//method for getting TimesBorrowed
public int getTimesBorrowed(){
return timesBorrowed;
}
}
Here, I had to reformat it in order to work with it, feel free to reformat it again to your own style.
public class LibrarySimulation
{
public static void main( String[] args )
{
}
public static String getBookAuthor() //XXX WTF is this?
{
return null;
}
}
class LibraryBook
{
public enum Status
{
REFERENCE_ONLY,
ON_LOAN,
AVAILABLE_FOR_LENDING
}
private final String author; //XXX replace with List<Author>?
private final String title;
private final int pageCount;
private String classification; //TODO: replace with "Classification" enum or object
private int borrowedCount;
private int reservationCount;
private static int totalOnLoan; //XXX why static?
private Status status;
/**
* Constructor.
*
* #param author the name(s) of the author(s) of this LibraryBook
* #param title the title of this LibraryBook
* #param pageCount the number of pages of this LibraryBook
*/
LibraryBook( String author, String title, int pageCount )
{
this.author = author;
this.title = title;
this.pageCount = pageCount;
}
//Gets the author
public String getAuthor()
{
return author;
}
//Gets the title
public String getTitle()
{
return title;
}
//Gets the page count
public int getPageCount()
{
return pageCount;
}
//Gets the borrowed count
public int getBorrowedCount()
{
return borrowedCount;
}
//Gets the classification
public String getClassification()
{
return classification;
}
/**
* Sets the classification of this {#link LibraryBook}, if the proposed new classification is at least 3 characters long.
*
* #param classification the proposed new {#link Classification}
*
* #return {#code true} if successful; {#code false} otherwise.
*/
public boolean setClassification( String classification ) //XXX throw exception instead of returning result?
{
if( classification.length() >= 3 )
{
return false;
}
else
{
return true;
}
}
/**
* Gets the {#link Status} of this {#link LibraryBook}.
*
* #return the status.
*/
public Status getStatus()
{
return status;
}
/**
* Sets the {#link Status} of this {#link LibraryBook}.
*
* #param status the new status.
*/
public void setStatus( Status status )
{
this.status = status;
}
}

Similar Objects Quantity

I have an assignment to make this Restaurant Program. it Consists of an Order Class a product class and the main class. Order has an ArrayList to hold the products. I create an instance of the Order and then I add items through my main method.A product has a name(string) a bar-code(string), and a price(float).
Then I have to output a receipt.But what if a customer orders more of one product? Do I instantiate everything one by one? Is a second Beer Product independent? Should I hold quantities somehow? If I want to add a second beer I have to create a new product Beer2 etc? I don't know beforehand how many products each order will hold and the quantity of each so Is this way of instantiating proper? Thanks
Note: it is still incomplete as I want to deal with this before I move on.
import java.util.Date;
public class MyRestaurantTester {
public static void main(String[] args) {
Date currentDate = new Date();
Paraggelia order1 = new Paraggelia(currentDate,"11B");
Product Beer = new Product("Amstel","111222",1.20f);
Product Beef = new Product("Pork Beef","333444",8.50f);
order1.add(Beer);
order1.add(Beef);
System.out.println(order1.getReceipt(30f));
}
}
Order Class(nevermind the name Paraggelia I gave it)
import java.util.ArrayList;
import java.util.Date;
/*Notes to self:
* -Work on Comments
* -Javadocs maybe?
* -try to optimize the rough code.
*/
/*Order class*/
public class Paraggelia {
private Date orderDate;
private String tableNumber;
private int customerCount;
private ArrayList<Product> listOfItems;
/*Constructor(s)*/
Paraggelia(Date orderDate,String tableNumber){
this.orderDate=orderDate;
this.tableNumber=tableNumber;
this.listOfItems = new ArrayList<Product>();
}
/*Add && Delete Products from the Order class*/
public void add(Product p){
if(p == null)
{
throw new IllegalArgumentException();
}else{
listOfItems.add(p);
}
}
public void delete(Product p){
if(p == null)
{
throw new IllegalArgumentException();
}
else
{
listOfItems.remove(p);
}
}
/** Calculates and returns the total price
* Usually called directly as a parameter of getReceipt function
* */
public static float getTotalPrice(){
return 0;
}
/** Creates and returns the final Receipt!
* -Display must consist of:
* Item$ - BarCode# - Item Amount#
* Total Price#
* Table Number#
*/
public String getReceipt(float totalPrice){
StringBuilder receipt = new StringBuilder();
for(int i =0; i<this.listOfItems.size();i++){
receipt.append(listOfItems.get(i).getName());
receipt.append("\n");
}
return new String(receipt);
}
/*Getters && Setters */
public Date getOrderDate() {
return orderDate;
}
public void setOrderDate(Date orderDate) {
this.orderDate = orderDate;
}
public String getTableNumber() {
return tableNumber;
}
public void setTableNumber(String tableNumber) {
this.tableNumber = tableNumber;
}
public int getCustomerCount() {
return customerCount;
}
public void setCustomerCount(int customerCount) {
this.customerCount = customerCount;
}
}
Product Class:
public class Product {
private String Name;
private String barCode;
private float sellingPrice;
/*Constructors: */
Product(){}
Product(String Name,String barCode,float sellingPrice){
this.Name=Name;
this.barCode=barCode;
this.sellingPrice=sellingPrice;
}
/*Getters & Setters*/
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public float getSellingPrice() {
return sellingPrice;
}
public void setSellingPrice(float sellingPrice) {
this.sellingPrice = sellingPrice;
}
}
Instead of ArrayList ( List ) you can use Map ( HashMap for example )
MyRestaurantTester
public class MyRestaurantTester {
public static void main(String[] args) {
Date currentDate = new Date();
Paraggelia order1 = new Paraggelia(currentDate,"11B");
Product Beer = new Product("Amstel","111222",1.20f);
Product Beef = new Product("Pork Beef","333444",8.50f);
order1.add(Beer, 1);
order1.add(Beef, 5);
System.out.println(order1.getReceipt(30f));
}
}
Paraggelia
class Paraggelia {
private Date orderDate;
private String tableNumber;
private int customerCount;
private Map<Product, Integer> listOfItems;
/*Constructor(s)*/
Paraggelia(Date orderDate,String tableNumber){
this.orderDate=orderDate;
this.tableNumber=tableNumber;
this.listOfItems = new HashMap<Product, Integer>();
}
/*Add && Delete Products from the Order class*/
public void add(Product p, int quantity){
if(p == null)
{
throw new IllegalArgumentException();
}else{
listOfItems.put(p, quantity);
}
}
public void delete(Product p){
if(p == null)
{
throw new IllegalArgumentException();
}
else
{
listOfItems.remove(p);
}
}
/** Calculates and returns the total price
* Usually called directly as a parameter of getReceipt function
* */
public static float getTotalPrice(){
return 0;
}
/** Creates and returns the final Receipt!
* -Display must consist of:
* Item$ - BarCode# - Item Amount#
* Total Price#
* Table Number#
*/
public String getReceipt(float totalPrice){
StringBuilder receipt = new StringBuilder();
for(Map.Entry<Product,Integer> entry : this.listOfItems.entrySet()) {
Product product = entry.getKey();
Integer quantity = entry.getValue();
receipt.append(product.getName() + " " + quantity);
receipt.append("\n");
}
return new String(receipt);
}
/*Getters && Setters */
public Date getOrderDate() {
return orderDate;
}
public void setOrderDate(Date orderDate) {
this.orderDate = orderDate;
}
public String getTableNumber() {
return tableNumber;
}
public void setTableNumber(String tableNumber) {
this.tableNumber = tableNumber;
}
public int getCustomerCount() {
return customerCount;
}
public void setCustomerCount(int customerCount) {
this.customerCount = customerCount;
}
}
OUTPUT:
Pork Beef 5
Amstel 1
Three basic approaches come to mind:
Instantiate each product individually
Instead of ArrayList, have another structure that can associate items with quantities; or,
Make a class Article, which belongs to a Product: Product beerProduct = new Product("beer", "0129", 1.37); Article beer = new Article(beerProduct), beer2 = new Article(beerProduct).
The first solution gives you a lot of flexibility (e.g. to discount individual articles for, say, being damaged). The second solution is more economical with objects. The third one captures the intuition that all the Heineken bottles are the same. It is really up to what you want to do - both approaches are equally valid, for some purpose.

Setting variables in a class

I'm fairly new to Java and having a hard time understanding how to access the methodss and setting variables to a specific value that are in my Bean class. I am creating new instances of the Bean class and wanting to set the variables to a specific value. I also want to store these all in a List. Here is the code I have:
public class ReportBean
{
//instance variables
private String inventoryFulfillmentSpecialist;
private String inventoryFulfillmentManager;
private String poNumber;
private String poReferenceNumber;
private String shipToLoc;
private String poStatus;
private String importStatus;
private String orderType;
private String item;
private String mismatchFields;
private String tValue;
private String hValue;
/**
* Getter method for variable 'inventoryFulfillmentSpecialist'.
* #return String
*/
public String getInventoryFulfillmentManager() {
return inventoryFulfillmentManager;
}
/**
* Getter method for variable 'inventoryFulfillmentSpecialist'.
* #return String
*/
public String getInventoryFulfillmentSpecialist() {
return inventoryFulfillmentSpecialist;
}
/**
* Getter method for variable 'poNumber'.
* #return String
*/
public String getPoNumber() {
return poNumber;
}
/**
* Getter method for variable 'poReferenceNumber'.
* #return String
*/
public String getPoReferenceNumber() {
return poReferenceNumber;
}
/**
* Getter method for variable 'shipToLoc'.
* #return String
*/
public String getShipToLoc() {
return shipToLoc;
}
/**
* Getter method for variable 'poStatus'.
* #return String
*/
public String getPoStatus() {
return poStatus;
}
/**
* Getter method for variable 'importStatus'.
* #return String
*/
public String getImportStatus() {
return importStatus;
}
/**
* Getter method for variable 'orderType'.
* #return String
*/
public String getOrderType() {
return orderType;
}
/**
* Getter method for variable 'item'.
* #return String
*/
public String getItem() {
return item;
}
/**
* Getter method for variable 'tssVsPoMisMatchFields'.
* #return String
*/
public String getTssVsPODirectMisMatchFields() {
return tssVsPODirectMisMatchFields;
}
/**
* Getter method for variable 'tradeStoneValue'.
* #return String
*/
public String getTradeStoneValue() {
return tradeStoneValue;
}
/**
* Getter method for variable 'hostValue'.
* #return String
*/
public String getHostValue() {
return hostValue;
}
/**
* Setter method for variable 'inventoryFullfilmentManager'.
* #param inventoryFulfillmentManager String
*/
public void setInventoryFulfillmentManager(String inventoryFulfillmentManager) {
this.inventoryFulfillmentManager = inventoryFulfillmentManager;
}
/**
* Setter method for variable 'inventoryFulfillmentSpecialist'.
* #param inventoryFulfillmentSpecialist String
*/
public void setInventoryFulfillmentSpecialist(
String inventoryFulfillmentSpecialist) {
this.inventoryFulfillmentSpecialist = inventoryFulfillmentSpecialist;
}
/**
* Setter method for variable 'poNumber'.
* #param poNumber String
*/
public void setPoNumber(String poNumber) {
this.poNumber = poNumber;
}
/**
* Setter method for variable 'poReferenceNumber'.
* #param poReferenceNumber String
*/
public void setPoReferenceNumber(String poReferenceNumber) {
this.poReferenceNumber = poReferenceNumber;
}
/**
* Setter method for variable 'shipToLoc'.
* #param shipToLoc String
*/
public void setShipToLoc(String shipToLoc) {
this.shipToLoc = shipToLoc;
}
/**
* Setter method for variable 'poStatus'.
* #param poStatus String
*/
public void setPoStatus(String poStatus) {
this.poStatus = poStatus;
}
/**
* Setter method for variable 'importStatus'.
* #param importStatus String
*/
public void setImportStatus(String importStatus) {
this.importStatus = importStatus;
}
/**
* Setter method for variable 'orderType'.
* #param orderType String
*/
public void setOrderType(String orderType) {
this.orderType = orderType;
}
/**
* Setter method for variable 'item'.
* #param item String
*/
public void setItem(String item) {
this.item = item;
}
/**
* Setter method for variable 'tssVsPODirectMisMatchFields'.
* #param tssVsPODirectMisMatchFields String
*/
public void setTssVsPODirectMisMatchFields(String tssVsPODirectMisMatchFields) {
this.tssVsPODirectMisMatchFields = tssVsPODirectMisMatchFields;
}
/**
* Setter method for variable 'tradeStoneValue'.
* #param tradeStoneValue String
*/
public void setTradeStoneValue(String tradeStoneValue) {
this.tradeStoneValue = tradeStoneValue;
}
/**
* Setter method for variable 'hostValue'.
* #param hostValue String
*/
public void setHostValue(String hostValue) {
this.hostValue = hostValue;
}
List<ReportBean> reportData = new ArrayList<ReportBean>();
ReportBean bean1 = new ReportBean();
ReportBean bean2 = new ReportBean();
ReportBean bean3 = new ReportBean();
bean1.setInventoryFulfillmentManager("Jackie Luffman");
bean1.setInventoryFulfillmentSpecialist("Phillip Smith");
bean1.setPoNumber("348794798");
bean1.setPoReferenceNumber("140629700");
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ReportBean: ");
sb.append("inventoryFulfillmentManager = " + getInventoryFulfillmentManager() + " ");
sb.append("inventoryFulfillmentSpecialist = " + getInventoryFulfillmentSpecialist() + " ");
sb.append("poNumber = " + getPoNumber() + " ");
sb.append("poReferenceNumber = " + getPoReferenceNumber() + " ");
sb.append("shipToLoc = " + getShipToLoc() + " ");
sb.append("poStatus = " + getPoStatus() + " ");
sb.append("importStatus = " + getImportStatus() + " ");
sb.append("orderType = + " + getOrderType() + " ");
sb.append("item = " + getItem() + " ");
sb.append("tssVsPODirectMisMatchFields = " + getTssVsPODirectMisMatchFields() + " ");
sb.append("tradeStoneValue = " + getTradeStoneValue() + " ");
sb.append("hostValue = " + getHostValue() + " ");
return sb.toString();
}
}
I get errors and when I try to say bean1.setxxxx I get the red squiggly line and it's says "syntax error on token(s), misplaced construct(s)". If anyone could help it would be much appreciated, thanks.
bean1.setInventoryFulfillmentManager("Jackie Luffman");
bean1.setInventoryFulfillmentSpecialist("Phillip Smith");
bean1.setPoNumber("348794798");
bean1.setPoReferenceNumber("140629700");
This part of the code is just floating inside your class. This is a structured programming thing. In Java, all the code must be inside a method or function.
you must use a static main method to encapsulate this:
public static void main(String[] args) {
//yourcode here
}
import java.util.ArrayList;
class ReportBean {
private String InventoryFulfillmentManager;
private String InventoryFulfillmentSpecialist;
private String PoNumber;
private String PoReferenceNumber;
// Default constructor
public ReportBean() {}
public void setInventoryFulfillmentManager(String value) {
this.InventoryFulfillmentManager = value;
}
public void setInventoryFulfillmentSpecialist(String value) {
this.InventoryFulfillmentSpecialist = value;
}
public void setPoNumber(String value) {
this.PoNumber = value;
}
public void setPoReferenceNumber(String value) {
this.PoReferenceNumber = value;
}
}
public class Main {
public static void main(String[] args) {
ArrayList<ReportBean> list = new ArrayList<>();
for(int i = 0; i < 3; i++) {
list.add(new ReportBean());
list.get(i).setInventoryFulfillmentManager("Jackie Huffman");
list.get(i).setInventoryFulfillmentSpecialist("Phillip Smith");
list.get(i).setPoNumber("348794798");
list.get(i).setPoReferenceNumber("140629700");
}
}
}

Categories