i am new to java and i thought i want to experiment. i am making a program that is more of a timeline from 2007 to 2017 of iphones , each year has the iphone name, memory size, description and the profit made. i am able to display all that information but i now want users to be able to input a new event, like a new iphone, what the memory size is and the profit made. so far all the information just prints in the console like this:
Name:Iphone (2007)
Year:2007
Minimum Memeory Size avalible:4
Maximum MemorySize avaliable:16
iphone Details:It is the first generation of iPhone that was
announced on January 9, 2007
Profit made in (billions $):2.0
but now i want the user to input a new phone like for example
enter the iphone year:
enter the name of the iphone:
enter minimum memory size:
this is what my first class looks like:
import java.io.*;
public class iphoneDescriptions {
String nameOfPhone;
int year;
int MinMemorySize;
int MaxMemorySize;
String details;
double profit;
String Creator;
//String iphonemaker;
public iphoneDescriptions(String nameOfPhone) {
this.nameOfPhone = nameOfPhone;
}
// public void iphoneDescriptions(String string) {
//this.nameOfPhone = nameOfPhone;
//}
public void iphoneYear(int iphoneYear) {
year = iphoneYear;
}
public void MaxMemorySize(int iphoneMaxMemorySize) {
MaxMemorySize = iphoneMaxMemorySize;
}
public void MinMemorySize(int iphoneMinMemorySize) {
MinMemorySize = iphoneMinMemorySize;
}
public void iphoneDetails(String iphoneDetails) {
details = iphoneDetails;
}
public void Creator (String iphonemaker) {
Creator = iphonemaker;
}
public void ProfitMade(double ProfitMade) {
profit = ProfitMade;
}
/* Print the Employee details */
public void printiphoneDescriptions() {
System.out.println("Name:"+ nameOfPhone );
System.out.println("Year:" + year );
System.out.println("Minimum Memeory Size avalible:" + MinMemorySize);
System.out.println("Maximum MemorySize avaliable:" + MaxMemorySize );
System.out.println("iphone Details:" + details);
System.out.println("Profit made in (billions $):" + profit);
// System.out.println("Name of the creator:" + Creator);
}
public void setIphone(String nameOfPhone) {
this.nameOfPhone = nameOfPhone;
}
public String getIphone() {
return nameOfPhone;
}
public void setCreator (String iphonemaker) {
this.Creator = iphonemaker;
}
public String getCreator() {
return Creator;
}
public void setiphoneDetails(String nameOfPhone) {
this.nameOfPhone = nameOfPhone;
}
public String getiphoneDetails() {
return nameOfPhone;
}
//public void setCreator1 (String iphonemaker) {
//this.iphonemaker = iphonemaker;
//}
//public String getCreator1() {
//return Creator;
}
and my second class:
import java.io.*;
public class Iphone {
public static void main(String args[]) {
/* Create two objects using constructor */
iphoneDescriptions Iphone1 = new iphoneDescriptions("Iphone (2007)");
Iphone1.iphoneYear(2007);
Iphone1.MinMemorySize(4);
Iphone1.MaxMemorySize(16);
Iphone1.iphoneDetails("It is the first generation of iPhone that was\r\n announced on January 9, 2007");
Iphone1.ProfitMade(2.0);
Iphone1.printiphoneDescriptions();
}
}