- Inside of an Eclipse Workspace, create a new Java project and call it whatever you want
- Press finish and inside of src create 2 new Classes called 'MobilePhone' and 'Main'
- Inside of 'Main' define a main method
- Start your assignment
- Open the Git perspective: In Eclipse, select "Window" -> "Perspective" -> "Open Perspective" -> "Other...". Choose "Git" from the list and click "OK".
- Clone the repository: Click on the "Clone a Git repository" icon in the Git perspective toolbar.
- Provide the clone URL: Paste the clone URL of the GitHub project into the "URI" field in the "Clone Git Repository" dialog.
- Authenticate (if required): Enter your GitHub credentials if prompted.
- Configure the local destination: Choose a directory for the project's local copy.
- Select branch or tag (optional): Choose a specific branch or leave it as the default.
- Import the project: On the "Import Projects" screen, select the repository and click "Next".
- Choose project import options: Select the project(s) you want to import and customize import options as needed. Click "Finish".
- Wait for the import process: Eclipse will import the project(s) and display progress in the "Progress" view.
- Open the imported project(s): The project(s) will be available in the Package Explorer or Project Explorer view in Eclipse.
- Start your assignment
We are going to create a MobilePhone class that defines a series of phone-related fields and methods using our knowledge of Java Object-Oriented-Programming. Then, we are going to create some custom MobilePhone objects in a different class to demonstrate that our custom class is accessible to other files!
- Please create 4 instance variables for our MobilePhone class:
- Brand
- Model
- Phone Number
- Storage Capacity
- Think about what data types would work best with these fields :)
-
Create a public constructor for our MobilePhone class Given 4 pieces of information as input (brand, model, operatingSystem, and storageCapacity), Set the instance variables of your object accordingly
-
Create getter and setter methods for each of our instance variables Please at least write 1 set of getters/setters by hand.
- After you get the hang of it, you can go to:
source(in the top left corner of Eclipse)generate getters and setters- checkmark all of the fields you want getters and setters for
generate
- After you get the hang of it, you can go to:
-
Lets make a couple custom phone-related methods:
- A makeCall method that takes a phone number as a parameter and then prints:
We are calling {the input phone number} from our {brand} {model} phone! - An installApp method that takes an app name String as input and then prints:
Installing {input app name} on our {brand} {model} phone! - Lastly, a displayInfo method that takes no parameters and prints all information about the phone:
Brand: {brand} Model: {model} Phone Number: {phone number} Storage Capacity: {storage capacity}GB - A makeCall method that takes a phone number as a parameter and then prints:
Inside of your main method, perform the following steps:
- Instantiate a brand new MobilePhone object and pass it the 4 parameters for your phone (Brand, Model, Phone Number, and Storage Capacity)
- Call the makeCall() method using your phone object - remember to pass it a phone number as input!
- Call the installApp() method using your phone object - remember to pass it an app name as input!
- Display your phone's information using the displayInfo() method!