Attached image(s)
Attached File(s)
-
GetInfo.zip (1.13K)
Number of downloads: 119




Posted 19 April 2010 - 09:15 PM
GetInfo.zip (1.13K)
Posted 19 April 2010 - 09:39 PM
Posted 20 April 2010 - 02:17 AM
macosxnerd101, on 19 April 2010 - 07:39 PM, said:
Posted 20 April 2010 - 02:23 AM
_marlon, on 20 April 2010 - 12:17 AM, said:
macosxnerd101, on 19 April 2010 - 07:39 PM, said:
Posted 20 April 2010 - 04:14 AM
Posted 20 April 2010 - 07:53 AM
macosxnerd101, on 20 April 2010 - 02:14 AM, said:
macosxnerd101, on 20 April 2010 - 02:14 AM, said:
Okay, so 11 hours later at 7am, this is what i have:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JOptionPane;
public class book
{
static Scanner console = new Scanner(System.in);
private String title;
private String publisher;
private String isbn;
private String copyRight;
private String author1;
private String author2;
private String author3;
private String author4;
private int NumOfCopies;
private double price;
private int authorCount;
//contstructor
void book(String constTitle,
String constPublisher, String constIsbn,String constCopyRight,
String constAuthor1 , String constAuthor2,String constAuthor3,
String constAuthor4, int constNumOfCopies,double constPrice,int constAuthorCount)
{
title = constTitle;
publisher = constPublisher;
isbn = constIsbn;
copyRight = constCopyRight;
author1 = constAuthor1;
author2 = constAuthor2;
author3 = constAuthor3;
author4 = constAuthor4;
NumOfCopies = constNumOfCopies;
price = constPrice;
authorCount = constAuthorCount;
}
// Start of Set Method
void setTitle(String constTitle)
{
title = constTitle;
}
void setPublisher(String constPublisher)
{
publisher = constPublisher;
}
void setIsbn(String constIsbn)
{
isbn = constIsbn;
}
void setCopyRight(String constCopyRight)
{
copyRight = constCopyRight;
}
void setAuthor1(String constAuthor1)
{
author1 = constAuthor1;
}
void setAuthor2(String constAuthor2)
{
author2 = constAuthor2;
}
void setAuthor3(String constAuthor3)
{
author3 = constAuthor3;
}
void setAuthor4(String constAuthor4)
{
author4 = constAuthor4;
}
void setNumOfCopies(int constNumOfCopies)
{
NumOfCopies = constNumOfCopies;
}
void setPrice(float constPrice)
{
price = constPrice;
}
void setAuthorCount(int constAuthorCount)
{
authorCount = constAuthorCount;
}
// End of Set Method
// Start of Get Methods
public String getTitle()
{
title = JOptionPane.showInputDialog("Enter title:");
return title;
}
String getPublisher()
{
publisher = JOptionPane.showInputDialog("Enter publisher:");
return publisher;
}
String getIsbn()
{
isbn = JOptionPane.showInputDialog("Enter ISBN:");
return isbn;
}
String getCopyRight()
{
copyRight = JOptionPane.showInputDialog("Enter copy right:");
return copyRight;
}
String getAuthor1()
{
author1 = JOptionPane.showInputDialog("Enter author 1:");
return author1;
}
String getAuthor2()
{
author2 = JOptionPane.showInputDialog("Enter author 2:");
return author2;
}
String getAuthor3()
{
author3 = JOptionPane.showInputDialog("Enter author 3:");
return author3;
}
String getAuthor4()
{
author4 = JOptionPane.showInputDialog("Enter author 4:");
return author4;
}
double getPrice()
{
price = Float.parseFloat(JOptionPane.showInputDialog("Enter price:"));
return price;
}
int getNumOfCopies()
{
NumOfCopies = Integer.parseInt(JOptionPane.showInputDialog("Enter price:"));
return NumOfCopies;
}
// End of get Methods
//Start of authorCount Method
int getAuthorCount()
{
while (author1!=null)
{
authorCount++;
}
if (author2!=null)
{
authorCount++;
}
else if (author3!=null)
{
authorCount++;
}
else if (author4!=null)
{
authorCount++;
}
return authorCount;
}
//End of authorCount Method
//EOF
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JOptionPane;
public class bookTest
{
public static void main(String[]args)
{
String temp;
book getTitleObject = new book();
book getPublisherObject = new book();
book getIsbnObject = new book();
book getCopyRightObject = new book();
book getAuthor1Object = new book();
book getAuthor2Object = new book();
book getAuthor3Object = new book();
book getAuthor4Object = new book();
book getPriceObject = new book();
book getAuthorCountObject = new book();
book getNumOfCopiesObject = new book();
temp =
"This is your Title: "+getTitleObject.getTitle()+
"\n Publisher: "+getPublisherObject.getPublisher()+
"\n ISBN: "+getIsbnObject.getIsbn()+
"\n Copy Right: "+getCopyRightObject.getCopyRight()+
"\n Author1: "+getAuthor1Object.getAuthor1()+
"\n Author2: "+getAuthor2Object.getAuthor2()+
"\n Author3: "+getAuthor3Object.getAuthor3()+
"\n Author4: "+getAuthor2Object.getAuthor4()+
"\n Price: "+String.format("%.2f", getPriceObject.getPrice())+
"\n Num of Authors: "+getAuthorCountObject.getAuthorCount()+
"\n Num of Copies: " +getNumOfCopiesObject.getNumOfCopies();
JOptionPane.showMessageDialog(null,temp, " ",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
Posted 20 April 2010 - 11:44 AM
int getAuthorCount()
{
while (author1!=null)
{
authorCount++;
}
if (author2!=null)
{
authorCount++;
}
else if (author3!=null)
{
authorCount++;
}
else if (author4!=null)
{
authorCount++;
}
Posted 20 April 2010 - 05:05 PM
macosxnerd101, on 20 April 2010 - 09:44 AM, said:
int getAuthorCount()
{
while (author1!=null)
{
authorCount++;
}
if (author2!=null)
{
authorCount++;
}
else if (author3!=null)
{
authorCount++;
}
else if (author4!=null)
{
authorCount++;
}
Right, but how would you fix it? that's just the same code i gave earlier
Posted 20 April 2010 - 05:08 PM
Posted 20 April 2010 - 08:45 PM
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JOptionPane;
public class Book
{
static Scanner console = new Scanner(System.in);
private String title;
private String publisher;
private String isbn;
private String copyRight;
private String author1;
private String author2;
private String author3;
private String author4;
private int copies;
private double price;
private int authorCount;
//contstructor
void book(String constTitle,
String constPublisher, String constIsbn,String constCopyRight,
String constAuthor1 , String constAuthor2,String constAuthor3,
String constAuthor4, int constCopies,double constPrice,int constAuthorCount)
{
title = constTitle;
publisher = constPublisher;
isbn = constIsbn;
copyRight = constCopyRight;
author1 = constAuthor1;
author2 = constAuthor2;
author3 = constAuthor3;
author4 = constAuthor4;
copies = constCopies;
price = constPrice;
authorCount = constAuthorCount;
}
// Start of Set Method
void setTitle(String constTitle)
{
title = constTitle;
}
void setPublisher(String constPublisher)
{
publisher = constPublisher;
}
void setIsbn(String constIsbn)
{
isbn = constIsbn;
}
void setCopyRight(String constCopyRight)
{
copyRight = constCopyRight;
}
void setAuthor1(String constAuthor1)
{
author1 = constAuthor1;
}
void setAuthor2(String constAuthor2)
{
author2 = constAuthor2;
}
void setAuthor3(String constAuthor3)
{
author3 = constAuthor3;
}
void setAuthor4(String constAuthor4)
{
author4 = constAuthor4;
}
void setCopies(int constCopies)
{
copies = constCopies;
}
void setPrice(float constPrice)
{
price = constPrice;
}
void setAuthorCount(int constAuthorCount)
{
authorCount = constAuthorCount;
}
// End of Set Method
// Start of Get Methods
public String getTitle()
{
title = JOptionPane.showInputDialog("Enter title: ");
return title;
}
String getPublisher()
{
publisher = JOptionPane.showInputDialog("Enter publisher: ");
return publisher;
}
String getIsbn()
{
isbn = JOptionPane.showInputDialog("Enter ISBN: ");
return isbn;
}
String getCopyRight()
{
copyRight = JOptionPane.showInputDialog("Enter copy right: ");
return copyRight;
}
String getAuthor1()
{
author1 = JOptionPane.showInputDialog("Enter author 1: ");
return author1;
}
String getAuthor2()
{
author2 = JOptionPane.showInputDialog("Enter author 2: ");
return author2;
}
String getAuthor3()
{
author3 = JOptionPane.showInputDialog("Enter author 3: ");
return author3;
}
String getAuthor4()
{
author4 = JOptionPane.showInputDialog("Enter author 4: ");
return author4;
}
double getPrice()
{
price = Float.parseFloat(JOptionPane.showInputDialog("Enter price: "));
return price;
}
int getCopies()
{
copies = Integer.parseInt(JOptionPane.showInputDialog("Enter copies count: "));
return copies;
}
// End of get Methods
//Start of authorCount Method
int getAuthorCount()
{
if (author1!=null)
{
authorCount++;
}
else if (author2!=null)
{
authorCount++;
}
else if (author3!=null)
{
authorCount++;
}
else if (author4!=null)
{
authorCount++;
}
return authorCount;
}
//End of authorCount Method
//EOF
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JOptionPane;
public class BookTest
{
public static void main(String[]args)
{
String temp;
Book b1 = new Book();
temp =
"This is your Title: "+b1.getTitle()+
"\n Publisher: "+b1.getPublisher()+
"\n ISBN: "+b1.getIsbn()+
"\n Copy Right: "+b1.getCopyRight()+
"\n Author1: "+b1.getAuthor1()+
"\n Author2: "+b1.getAuthor2()+
"\n Author3: "+b1.getAuthor3()+
"\n Author4: "+b1.getAuthor4()+
"\n Price: "+String.format("%.2f", b1.getPrice())+
"\n Num of Authors: "+b1.getAuthorCount()+
"\n Num of Copies: " +b1.getCopies();
JOptionPane.showMessageDialog(null,temp, " ",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
Posted 21 April 2010 - 07:03 AM
Posted 21 April 2010 - 10:07 AM
macosxnerd101, on 21 April 2010 - 05:03 AM, said:
Posted 21 April 2010 - 10:11 AM
Posted 21 April 2010 - 10:43 AM
Posted 21 April 2010 - 12:24 PM
macosxnerd101, on 21 April 2010 - 08:11 AM, said:
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
