Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- MobilePhone phone = new MobilePhone("200 grammes", 1500);
- String parameters = phone.getParameters();
- System.out.println(parameters);
- phone.displayPrice ();
- phone.lowerPrice ();
- phone.higherPrice ( 500 );
- }
- }
- class MobilePhone {
- String weight;
- int price;
- public MobilePhone ( String weight, int price ) {
- this.weight = weight;
- this.price = price;
- }
- public void displayValues ( ) {
- System.out.println ( this.weight + " " + this.price );
- }
- public String getParameters ( ) {
- return "This phone weights " + this.weight + ", and it's nominal price is " + this.price;
- }
- public void displayPrice ( ) {
- System.out.println("This phone's price is " + this.price + "zł");
- }
- public void lowerPrice ( ) {
- int percent = (this.price * 10) / 100;
- this.price = (this.price - percent);
- System.out.println ("\n\n ***SPECIAL OFFER!!***\n\n BUY TODAY " +
- "AND SAVE 10% OF IT'S PRICE!!! \n\n " + this.price + "zł" +
- "\n\nSEE HOW MUCH YOU SAVE!!" );
- }
- public void higherPrice (int a){
- int x = this.price + a;
- System.out.println ("****LAST CHANCE!! TOMORROW THE PRICE WILL SKYROCKET TO****\n\n" + x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement